Skip to content

Commit e8e77ca

Browse files
committed
Test
1 parent 5d4c00f commit e8e77ca

File tree

2 files changed

+305
-0
lines changed

2 files changed

+305
-0
lines changed
Lines changed: 250 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,250 @@
1+
name: Test tarball cross-platform compatibility
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- "packages/eas-cli/src/build/utils/repository.ts"
7+
- ".github/workflows/test-tarball-cross-platform.yml"
8+
workflow_dispatch:
9+
10+
jobs:
11+
create-tarball-windows:
12+
name: Create tarball on Windows
13+
runs-on: windows-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Setup node
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version: "20"
21+
22+
- name: Install dependencies
23+
run: yarn install --frozen-lockfile
24+
25+
- name: Setup git config
26+
run: |
27+
git config --global user.email "[email protected]"
28+
git config --global user.name "CI Test"
29+
30+
- name: Create test git repository
31+
run: |
32+
mkdir test-project
33+
cd test-project
34+
git init
35+
git config user.email "[email protected]"
36+
git config user.name "CI Test"
37+
38+
# Create directory structure with files
39+
New-Item -ItemType Directory -Force -Path src/api, src/app, src/assets
40+
"console.log('api');" | Out-File -Encoding utf8 src/api/index.js
41+
"console.log('app');" | Out-File -Encoding utf8 src/app/index.js
42+
"/* asset */" | Out-File -Encoding utf8 src/assets/style.css
43+
"test content" | Out-File -Encoding utf8 README.md
44+
45+
git add .
46+
git commit -m "Initial commit"
47+
shell: pwsh
48+
49+
- name: Build eas-cli
50+
run: yarn build
51+
working-directory: ./packages/eas-cli
52+
53+
- name: Create tarball
54+
run: |
55+
cd test-project
56+
node ../bin/run build:test-tarball --output ../test-project.tar.gz
57+
echo "Created tarball on Windows"
58+
shell: pwsh
59+
60+
- name: Upload tarball artifact
61+
uses: actions/upload-artifact@v4
62+
with:
63+
name: windows-tarball
64+
path: test-project.tar.gz
65+
retention-days: 1
66+
67+
test-extract-linux:
68+
name: Extract and test on Linux
69+
runs-on: ubuntu-latest
70+
needs: create-tarball-windows
71+
steps:
72+
- name: Download tarball from Windows
73+
uses: actions/download-artifact@v4
74+
with:
75+
name: windows-tarball
76+
77+
- name: Extract tarball
78+
run: |
79+
mkdir extracted
80+
tar -C extracted --strip-components 1 -zxf test-project.tar.gz
81+
echo "✅ Extraction successful!"
82+
83+
- name: Verify directory structure
84+
run: |
85+
cd extracted
86+
if [ ! -d "src/api" ]; then
87+
echo "❌ src/api directory not found"
88+
exit 1
89+
fi
90+
if [ ! -d "src/app" ]; then
91+
echo "❌ src/app directory not found"
92+
exit 1
93+
fi
94+
if [ ! -d "src/assets" ]; then
95+
echo "❌ src/assets directory not found"
96+
exit 1
97+
fi
98+
echo "✅ All directories extracted successfully"
99+
100+
- name: Verify files are readable
101+
run: |
102+
cd extracted
103+
cat src/api/index.js
104+
cat src/app/index.js
105+
cat src/assets/style.css
106+
cat package.json
107+
echo "✅ All files are readable"
108+
109+
- name: List permissions
110+
run: |
111+
cd extracted
112+
ls -la
113+
ls -la src/
114+
ls -la src/api/
115+
ls -la src/app/
116+
ls -la src/assets/
117+
118+
test-extract-macos:
119+
name: Extract and test on macOS
120+
runs-on: macos-latest
121+
needs: create-tarball-windows
122+
steps:
123+
- name: Download tarball from Windows
124+
uses: actions/download-artifact@v4
125+
with:
126+
name: windows-tarball
127+
128+
- name: Extract tarball
129+
run: |
130+
mkdir extracted
131+
tar -C extracted --strip-components 1 -zxf test-project.tar.gz
132+
echo "✅ Extraction successful!"
133+
134+
- name: Verify directory structure
135+
run: |
136+
cd extracted
137+
if [ ! -d "src/api" ]; then
138+
echo "❌ src/api directory not found"
139+
exit 1
140+
fi
141+
if [ ! -d "src/app" ]; then
142+
echo "❌ src/app directory not found"
143+
exit 1
144+
fi
145+
if [ ! -d "src/assets" ]; then
146+
echo "❌ src/assets directory not found"
147+
exit 1
148+
fi
149+
echo "✅ All directories extracted successfully"
150+
151+
- name: Verify files are readable
152+
run: |
153+
cd extracted
154+
cat src/api/index.js
155+
cat src/app/index.js
156+
cat src/assets/style.css
157+
cat package.json
158+
echo "✅ All files are readable"
159+
160+
# Also test that Unix-created tarballs preserve permissions
161+
create-tarball-linux:
162+
name: Create tarball on Linux
163+
runs-on: ubuntu-latest
164+
steps:
165+
- uses: actions/checkout@v4
166+
167+
- name: Setup node
168+
uses: actions/setup-node@v4
169+
with:
170+
node-version: "20"
171+
172+
- name: Install dependencies
173+
run: yarn install --frozen-lockfile
174+
175+
- name: Setup git config
176+
run: |
177+
git config --global user.email "[email protected]"
178+
git config --global user.name "CI Test"
179+
180+
- name: Create test git repository with executable files
181+
run: |
182+
mkdir test-project-linux
183+
cd test-project-linux
184+
git init
185+
git config user.email "[email protected]"
186+
git config user.name "CI Test"
187+
188+
# Create directory structure
189+
mkdir -p src/api src/app scripts
190+
echo "console.log('api');" > src/api/index.js
191+
echo "console.log('app');" > src/app/index.js
192+
193+
# Create an executable script
194+
cat > scripts/build.sh << 'EOF'
195+
#!/bin/bash
196+
echo "Building..."
197+
EOF
198+
chmod +x scripts/build.sh
199+
200+
echo "test content" > README.md
201+
202+
git add .
203+
git commit -m "Initial commit"
204+
205+
- name: Build eas-cli
206+
run: yarn build
207+
working-directory: ./packages/eas-cli
208+
209+
- name: Create tarball
210+
run: |
211+
cd test-project-linux
212+
node ../bin/run build:test-tarball --output ../test-project-linux.tar.gz
213+
214+
- name: Upload tarball artifact
215+
uses: actions/upload-artifact@v4
216+
with:
217+
name: linux-tarball
218+
path: test-project-linux.tar.gz
219+
retention-days: 1
220+
221+
verify-linux-permissions:
222+
name: Verify Linux tarball preserves executable permissions
223+
runs-on: ubuntu-latest
224+
needs: create-tarball-linux
225+
steps:
226+
- name: Download tarball from Linux
227+
uses: actions/download-artifact@v4
228+
with:
229+
name: linux-tarball
230+
231+
- name: Extract tarball
232+
run: |
233+
mkdir extracted
234+
tar -C extracted --strip-components 1 -zxf test-project-linux.tar.gz
235+
236+
- name: Verify executable permissions are preserved
237+
run: |
238+
cd extracted
239+
if [ ! -x "scripts/build.sh" ]; then
240+
echo "❌ scripts/build.sh is not executable!"
241+
ls -la scripts/build.sh
242+
exit 1
243+
fi
244+
echo "✅ Executable permissions preserved!"
245+
ls -la scripts/build.sh
246+
247+
- name: Test executing the script
248+
run: |
249+
cd extracted
250+
./scripts/build.sh
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import { Command, Flags } from '@oclif/core';
2+
import fs from 'fs-extra';
3+
4+
import { makeProjectTarballAsync } from '../../build/utils/repository';
5+
import GitClient from '../../vcs/clients/git';
6+
7+
/**
8+
* Test command to create a project tarball and verify it works cross-platform.
9+
* Used in CI to test that archives created on Windows can be extracted on Unix/Linux.
10+
* Does not require an Expo project - works with any git repository.
11+
*/
12+
export default class BuildTestTarball extends Command {
13+
static override hidden = true;
14+
static override description = 'Create a project tarball for testing cross-platform compatibility';
15+
16+
static override flags = {
17+
output: Flags.string({
18+
description: 'Output path for the tarball',
19+
required: false,
20+
}),
21+
cwd: Flags.string({
22+
description: 'Working directory (defaults to current directory)',
23+
required: false,
24+
}),
25+
};
26+
27+
async run(): Promise<void> {
28+
const { flags } = await this.parse(BuildTestTarball);
29+
const cwd = flags.cwd ?? process.cwd();
30+
31+
this.log(`Creating project tarball from ${cwd}...`);
32+
this.log(`Platform: ${process.platform}`);
33+
34+
const vcsClient = new GitClient({
35+
maybeCwdOverride: cwd,
36+
requireCommit: false,
37+
});
38+
39+
const { path: tarballPath, size } = await makeProjectTarballAsync(vcsClient);
40+
41+
this.log(`✅ Tarball created successfully: ${tarballPath}`);
42+
this.log(`Size: ${(size / 1024 / 1024).toFixed(2)} MB`);
43+
44+
if (flags.output) {
45+
await fs.copy(tarballPath, flags.output);
46+
this.log(`Copied to: ${flags.output}`);
47+
// Output just the path for easy consumption in CI
48+
console.log(flags.output);
49+
} else {
50+
// Output the path for easy consumption in CI
51+
console.log(tarballPath);
52+
}
53+
}
54+
}
55+

0 commit comments

Comments
 (0)