Skip to content

Commit 595834d

Browse files
committed
Test
1 parent 5d4c00f commit 595834d

File tree

2 files changed

+302
-0
lines changed

2 files changed

+302
-0
lines changed
Lines changed: 248 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,248 @@
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 "ci@expo.dev"
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 "ci@expo.dev"
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
50+
run: yarn build
51+
52+
- name: Create tarball
53+
run: |
54+
cd test-project
55+
node ../bin/run build:test-tarball --output ../test-project.tar.gz
56+
echo "Created tarball on Windows"
57+
shell: pwsh
58+
59+
- name: Upload tarball artifact
60+
uses: actions/upload-artifact@v4
61+
with:
62+
name: windows-tarball
63+
path: test-project.tar.gz
64+
retention-days: 1
65+
66+
test-extract-linux:
67+
name: Extract and test on Linux
68+
runs-on: ubuntu-latest
69+
needs: create-tarball-windows
70+
steps:
71+
- name: Download tarball from Windows
72+
uses: actions/download-artifact@v4
73+
with:
74+
name: windows-tarball
75+
76+
- name: Extract tarball
77+
run: |
78+
mkdir extracted
79+
tar -C extracted --strip-components 1 -zxf test-project.tar.gz
80+
echo "✅ Extraction successful!"
81+
82+
- name: Verify directory structure
83+
run: |
84+
cd extracted
85+
if [ ! -d "src/api" ]; then
86+
echo "❌ src/api directory not found"
87+
exit 1
88+
fi
89+
if [ ! -d "src/app" ]; then
90+
echo "❌ src/app directory not found"
91+
exit 1
92+
fi
93+
if [ ! -d "src/assets" ]; then
94+
echo "❌ src/assets directory not found"
95+
exit 1
96+
fi
97+
echo "✅ All directories extracted successfully"
98+
99+
- name: Verify files are readable
100+
run: |
101+
cd extracted
102+
cat src/api/index.js
103+
cat src/app/index.js
104+
cat src/assets/style.css
105+
cat package.json
106+
echo "✅ All files are readable"
107+
108+
- name: List permissions
109+
run: |
110+
cd extracted
111+
ls -la
112+
ls -la src/
113+
ls -la src/api/
114+
ls -la src/app/
115+
ls -la src/assets/
116+
117+
test-extract-macos:
118+
name: Extract and test on macOS
119+
runs-on: macos-latest
120+
needs: create-tarball-windows
121+
steps:
122+
- name: Download tarball from Windows
123+
uses: actions/download-artifact@v4
124+
with:
125+
name: windows-tarball
126+
127+
- name: Extract tarball
128+
run: |
129+
mkdir extracted
130+
tar -C extracted --strip-components 1 -zxf test-project.tar.gz
131+
echo "✅ Extraction successful!"
132+
133+
- name: Verify directory structure
134+
run: |
135+
cd extracted
136+
if [ ! -d "src/api" ]; then
137+
echo "❌ src/api directory not found"
138+
exit 1
139+
fi
140+
if [ ! -d "src/app" ]; then
141+
echo "❌ src/app directory not found"
142+
exit 1
143+
fi
144+
if [ ! -d "src/assets" ]; then
145+
echo "❌ src/assets directory not found"
146+
exit 1
147+
fi
148+
echo "✅ All directories extracted successfully"
149+
150+
- name: Verify files are readable
151+
run: |
152+
cd extracted
153+
cat src/api/index.js
154+
cat src/app/index.js
155+
cat src/assets/style.css
156+
cat package.json
157+
echo "✅ All files are readable"
158+
159+
# Also test that Unix-created tarballs preserve permissions
160+
create-tarball-linux:
161+
name: Create tarball on Linux
162+
runs-on: ubuntu-latest
163+
steps:
164+
- uses: actions/checkout@v4
165+
166+
- name: Setup node
167+
uses: actions/setup-node@v4
168+
with:
169+
node-version: "20"
170+
171+
- name: Install dependencies
172+
run: yarn install --frozen-lockfile
173+
174+
- name: Setup git config
175+
run: |
176+
git config --global user.email "ci@expo.dev"
177+
git config --global user.name "CI Test"
178+
179+
- name: Create test git repository with executable files
180+
run: |
181+
mkdir test-project-linux
182+
cd test-project-linux
183+
git init
184+
git config user.email "ci@expo.dev"
185+
git config user.name "CI Test"
186+
187+
# Create directory structure
188+
mkdir -p src/api src/app scripts
189+
echo "console.log('api');" > src/api/index.js
190+
echo "console.log('app');" > src/app/index.js
191+
192+
# Create an executable script
193+
cat > scripts/build.sh << 'EOF'
194+
#!/bin/bash
195+
echo "Building..."
196+
EOF
197+
chmod +x scripts/build.sh
198+
199+
echo "test content" > README.md
200+
201+
git add .
202+
git commit -m "Initial commit"
203+
204+
- name: Build
205+
run: yarn build
206+
207+
- name: Create tarball
208+
run: |
209+
cd test-project-linux
210+
node ../bin/run build:test-tarball --output ../test-project-linux.tar.gz
211+
212+
- name: Upload tarball artifact
213+
uses: actions/upload-artifact@v4
214+
with:
215+
name: linux-tarball
216+
path: test-project-linux.tar.gz
217+
retention-days: 1
218+
219+
verify-linux-permissions:
220+
name: Verify Linux tarball preserves executable permissions
221+
runs-on: ubuntu-latest
222+
needs: create-tarball-linux
223+
steps:
224+
- name: Download tarball from Linux
225+
uses: actions/download-artifact@v4
226+
with:
227+
name: linux-tarball
228+
229+
- name: Extract tarball
230+
run: |
231+
mkdir extracted
232+
tar -C extracted --strip-components 1 -zxf test-project-linux.tar.gz
233+
234+
- name: Verify executable permissions are preserved
235+
run: |
236+
cd extracted
237+
if [ ! -x "scripts/build.sh" ]; then
238+
echo "❌ scripts/build.sh is not executable!"
239+
ls -la scripts/build.sh
240+
exit 1
241+
fi
242+
echo "✅ Executable permissions preserved!"
243+
ls -la scripts/build.sh
244+
245+
- name: Test executing the script
246+
run: |
247+
cd extracted
248+
./scripts/build.sh
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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+
}

0 commit comments

Comments
 (0)