Skip to content

Commit 5874112

Browse files
Refactoring CI script
1 parent cf4e15a commit 5874112

File tree

3 files changed

+127
-276
lines changed

3 files changed

+127
-276
lines changed

.github/workflows/amazonlinux.yml

Lines changed: 0 additions & 37 deletions
This file was deleted.

.github/workflows/main.yml

Lines changed: 79 additions & 206 deletions
Original file line numberDiff line numberDiff line change
@@ -9,276 +9,149 @@ on:
99
branches:
1010
- swiftwasm
1111
- swiftwasm-release/5.3
12-
1312
jobs:
14-
ubuntu1804_build:
15-
timeout-minutes: 0
16-
runs-on: ubuntu-18.04
13+
build_toolchain:
14+
env:
15+
TOOLCHAIN_CHANNEL: DEVELOPMENT
16+
strategy:
17+
matrix:
18+
include:
19+
- build_os: ubuntu-18.04
20+
target: ubuntu18.04_x86_64
21+
run_full_test: false
22+
run_e2e_test: true
23+
build_hello_wasm: true
1724

18-
steps:
19-
- name: Free disk space
20-
run: |
21-
df -h
22-
sudo apt-get purge libgcc-9-dev gcc-9 libstdc++-9-dev clang-6.0 llvm-6.0
23-
sudo swapoff -a
24-
sudo rm -f /swapfile
25-
sudo rm -rf /opt/hostedtoolcache
26-
sudo rm -rf /usr/share/dotnet
27-
sudo apt clean
28-
docker rmi $(docker image ls -aq)
29-
df -h
30-
- uses: actions/checkout@v1
31-
with:
32-
path: swift
33-
- name: Prepare sccache timestamp
34-
id: cache_timestamp
35-
shell: cmake -P {0}
36-
run: |
37-
string(TIMESTAMP current_date "%Y-%m-%d-%H;%M;%S" UTC)
38-
message("::set-output name=timestamp::${current_date}")
39-
- uses: actions/cache@v1
40-
with:
41-
path: ../build-cache
42-
key: ubuntu-18.04-sccache-v10-${{ steps.cache_timestamp.outputs.timestamp }}
43-
restore-keys: |
44-
ubuntu-18.04-sccache-v10-
45-
- name: Build Ubuntu 18.04 installable archive
46-
run: |
47-
./utils/webassembly/ci.sh
48-
- name: Upload Ubuntu 18.04 installable archive
49-
uses: actions/upload-artifact@v1
50-
with:
51-
name: ubuntu18.04-installable
52-
path: ../swift-wasm-DEVELOPMENT-SNAPSHOT-ubuntu18.04_x86_64.tar.gz
53-
# - name: Pack test results
54-
# run: tar cJf swift-test-results.tar.gz ../build/*/swift-linux-x86_64/swift-test-results
55-
# - name: Upload test results
56-
# uses: actions/upload-artifact@v1
57-
# with:
58-
# name: linux-test-results
59-
# path: ./swift-test-results.tar.gz
25+
- build_os: ubuntu-20.04
26+
target: ubuntu20.04_x86_64
27+
run_full_test: false
28+
run_e2e_test: true
29+
build_hello_wasm: true
6030

61-
ubuntu2004_build:
62-
timeout-minutes: 0
63-
runs-on: ubuntu-20.04
31+
- build_os: ubuntu-20.04
32+
target: amazonlinux2_x86_64
33+
run_full_test: false
34+
run_e2e_test: false
35+
build_hello_wasm: false
6436

37+
- build_os: macos-10.15
38+
target: macos_x86_64
39+
run_full_test: true
40+
run_e2e_test: true
41+
build_hello_wasm: true
42+
43+
name: Target ${{ matrix.target }}
44+
timeout-minutes: 0
45+
runs-on: ${{ matrix.build_os }}
6546
steps:
6647
- name: Free disk space
48+
if: ${{ matrix.build_os == 'ubuntu-20.04' || matrix.build_os == 'ubuntu-18.04' }}
6749
run: |
6850
df -h
51+
sudo apt-get purge libgcc-9-dev gcc-9 libstdc++-9-dev clang-6.0 llvm-6.0
6952
sudo swapoff -a
7053
sudo rm -f /swapfile
7154
sudo rm -rf /opt/hostedtoolcache
7255
sudo rm -rf /usr/share/dotnet
7356
sudo apt clean
7457
docker rmi $(docker image ls -aq)
7558
df -h
76-
- uses: actions/checkout@v1
77-
with:
78-
path: swift
79-
- name: Prepare sccache timestamp
80-
id: cache_timestamp
81-
shell: cmake -P {0}
82-
run: |
83-
string(TIMESTAMP current_date "%Y-%m-%d-%H;%M;%S" UTC)
84-
message("::set-output name=timestamp::${current_date}")
85-
- uses: actions/cache@v1
86-
with:
87-
path: ../build-cache
88-
key: ubuntu-20.04-sccache-v10-${{ steps.cache_timestamp.outputs.timestamp }}
89-
restore-keys: |
90-
ubuntu-20.04-sccache-v10-
91-
- name: Build Ubuntu 20.04 installable archive
92-
run: |
93-
./utils/webassembly/ci.sh
94-
- name: Upload Ubuntu 20.04 installable archive
95-
uses: actions/upload-artifact@v1
96-
with:
97-
name: ubuntu20.04-installable
98-
path: ../swift-wasm-DEVELOPMENT-SNAPSHOT-ubuntu20.04_x86_64.tar.gz
99-
# - name: Pack test results
100-
# run: tar cJf swift-test-results.tar.gz ../build/*/swift-linux-x86_64/swift-test-results
101-
# - name: Upload test results
102-
# uses: actions/upload-artifact@v1
103-
# with:
104-
# name: linux-test-results
105-
# path: ./swift-test-results.tar.gz
106-
107-
macos_build:
108-
timeout-minutes: 0
109-
runs-on: macos-10.15
11059
111-
steps:
11260
- uses: actions/checkout@v1
11361
with:
11462
path: swift
63+
11564
- name: Prepare sccache timestamp
11665
id: cache_timestamp
11766
shell: cmake -P {0}
11867
run: |
11968
string(TIMESTAMP current_date "%Y-%m-%d-%H;%M;%S" UTC)
12069
message("::set-output name=timestamp::${current_date}")
70+
12171
- uses: actions/cache@v1
12272
with:
12373
path: ../build-cache
124-
key: ${{ runner.os }}-sccache-v10-${{ steps.cache_timestamp.outputs.timestamp }}
74+
key: ${{ matrix.target }}-sccache-v10-${{ steps.cache_timestamp.outputs.timestamp }}
12575
restore-keys: |
126-
${{ runner.os }}-sccache-v10-
127-
- name: Build macOS installable archive
76+
${{ matrix.target }}-sccache-v10-
77+
78+
- name: Select Xcode version
79+
if: ${{ matrix.build_os == 'macos-10.15' }}
12880
run: |
12981
sudo xcode-select --switch /Applications/Xcode_12.3.app/Contents/Developer/
13082
xcodebuild -version
131-
./utils/webassembly/ci.sh
83+
84+
- name: Build ${{ matrix.target }} installable archive
13285
env:
133-
SKIP_XCODE_VERSION_CHECK: 1 # Skip upstream update the compatible Xcode version
134-
- name: Upload macOS installable archive
86+
SKIP_XCODE_VERSION_CHECK: 1
87+
run: |
88+
89+
case "${{ matrix.target }}" in
90+
"ubuntu20.04_x86_64" | "ubuntu18.04_x86_64" | "macos_x86_64")
91+
./utils/webassembly/ci.sh
92+
;;
93+
"amazonlinux2_x86_64")
94+
SWIFT_IMAGE=swiftwasm-amazonlinux2_x86_64:nightly-$GITHUB_SHA
95+
docker build --build-arg SWIFT_GIT_SHA=$GITHUB_SHA \
96+
--tag $SWIFT_IMAGE ./utils/webassembly/amazonlinux
97+
docker run -v $GITHUB_WORKSPACE/../:/home/host-dir $SWIFT_IMAGE \
98+
cp -r /home/ec2-user/swift-wasm-$TOOLCHAIN_CHANNEL-SNAPSHOT-amazonlinux2_x86_64.tar.gz /home/host-dir
99+
;;
100+
*)
101+
echo "Unrecognised target: ${{ matrix.target }}"
102+
exit 1
103+
;;
104+
esac
105+
106+
- name: Upload ${{ matrix.target }} installable archive
135107
uses: actions/upload-artifact@v1
136108
with:
137-
name: macos-installable
138-
path: ../swift-wasm-DEVELOPMENT-SNAPSHOT-macos_x86_64.tar.gz
109+
name: ${{ matrix.target }}-installable
110+
path: ../swift-wasm-${{ env.TOOLCHAIN_CHANNEL }}-SNAPSHOT-${{ matrix.target }}.tar.gz
111+
139112
- name: Pack test results
113+
if: ${{ matrix.run_full_test }}
140114
working-directory: ${{ github.workspace }}/../
141115
run: |
142116
tar cJf ./swift/swift-test-results.tar.gz target-build/swift-stdlib-wasi-wasm32/swift-test-results
143117
- name: Upload test results
144118
uses: actions/upload-artifact@v1
119+
if: ${{ matrix.run_full_test }}
145120
with:
146-
name: macos-test-results
121+
name: ${{ matrix.target }}-test-results
147122
path: ./swift-test-results.tar.gz
148123

149-
macos_smoke_test:
150-
name: Run smoke tests on macOS
151-
runs-on: macos-10.15
152-
needs: macos_build
153-
steps:
154-
- name: Download installable macOS archive
155-
uses: actions/download-artifact@v1
156-
with:
157-
name: macos-installable
158-
- name: Unpack toolchain
124+
# Run e2e test
125+
- name: Run E2E test
126+
working-directory: ${{ github.workspace }}/../
159127
run: |
160-
set -x
161-
tar xf $(find . -name "swift-wasm-*.tar.gz" -type f)
162-
echo "TOOLCHAIN=$(find "$PWD" -name "swift-wasm-*" -type d)" >> $GITHUB_ENV
128+
tar xf swift-wasm-$TOOLCHAIN_CHANNEL-SNAPSHOT-${{ matrix.target }}.tar.gz
129+
echo "TOOLCHAIN=$(find "$PWD" -name "swift-wasm-$TOOLCHAIN_CHANNEL-*" -type d)" >> $GITHUB_ENV
163130
- name: Build hello.wasm
164131
shell: bash
132+
if: ${{ matrix.build_hello_wasm }}
165133
run: |
166134
echo 'print("Hello, world!")' > hello.swift
167135
$TOOLCHAIN/usr/bin/swiftc \
168136
-target wasm32-unknown-wasi \
169137
-sdk $TOOLCHAIN/usr/share/wasi-sysroot \
170138
hello.swift -o hello.wasm && \
171139
echo "Successfully linked hello.wasm"
172-
- name: Test SwiftPM
173-
shell: bash
174-
run: |
175-
set -x
176-
mkdir test
177-
cd test
178-
$TOOLCHAIN/usr/bin/swift package init
179-
$TOOLCHAIN/usr/bin/swift build --triple wasm32-unknown-wasi
180-
- name: Upload hello.wasm compiled with macOS package
140+
- name: Upload hello.wasm
141+
if: ${{ matrix.build_hello_wasm }}
181142
uses: actions/upload-artifact@v1
182143
with:
183-
name: macos-hello.wasm
144+
name: ${{ matrix.target }}-hello.wasm
184145
path: hello.wasm
185146
- name: Checkout integration-tests
147+
if: ${{ matrix.run_e2e_test }}
186148
uses: actions/checkout@v2
187149
with:
188150
repository: swiftwasm/integration-tests
189151
path: integration-tests
190152
- name: Run integration tests
153+
if: ${{ matrix.run_e2e_test }}
191154
run: |
192-
sudo xcode-select --switch /Applications/Xcode_12.2.app/Contents/Developer/
193155
swift run # Use TOOLCHAIN env value
194156
working-directory: ${{ github.workspace }}/integration-tests
195157

196-
ubuntu1804_smoke_test:
197-
name: Run smoke tests on Ubuntu 18.04
198-
runs-on: ubuntu-18.04
199-
needs: ubuntu1804_build
200-
steps:
201-
- name: Download installable Ubuntu 18.04 archive
202-
uses: actions/download-artifact@v1
203-
with:
204-
name: ubuntu18.04-installable
205-
- name: Unpack toolchain
206-
run: |
207-
set -x
208-
tar xf $(find . -name "swift-wasm-*.tar.gz" -type f)
209-
echo "TOOLCHAIN=$(find "$PWD" -name "swift-wasm-*" -type d)" >> $GITHUB_ENV
210-
- name: Build hello.wasm
211-
shell: bash
212-
run: |
213-
echo 'print("Hello, world!")' > hello.swift
214-
$TOOLCHAIN/usr/bin/swiftc \
215-
-target wasm32-unknown-wasi \
216-
-sdk $TOOLCHAIN/usr/share/wasi-sysroot \
217-
hello.swift -o hello.wasm && \
218-
echo "Successfully linked hello.wasm"
219-
- name: Test SwiftPM
220-
shell: bash
221-
run: |
222-
set -x
223-
mkdir test
224-
cd test
225-
$TOOLCHAIN/usr/bin/swift package init
226-
$TOOLCHAIN/usr/bin/swift build --triple wasm32-unknown-wasi
227-
- name: Upload hello.wasm compiled with Ubuntu 18.04 package
228-
uses: actions/upload-artifact@v1
229-
with:
230-
name: ubuntu18.04-hello.wasm
231-
path: hello.wasm
232-
- name: Checkout integration-tests
233-
uses: actions/checkout@v2
234-
with:
235-
repository: swiftwasm/integration-tests
236-
path: integration-tests
237-
- name: Run integration tests
238-
run: swift run # Use TOOLCHAIN env value
239-
working-directory: ${{ github.workspace }}/integration-tests
240-
241-
ubuntu2004_smoke_test:
242-
name: Run smoke tests on Ubuntu 20.04
243-
runs-on: ubuntu-20.04
244-
needs: ubuntu2004_build
245-
steps:
246-
- name: Download installable Ubuntu 20.04 archive
247-
uses: actions/download-artifact@v1
248-
with:
249-
name: ubuntu20.04-installable
250-
- name: Unpack toolchain
251-
run: |
252-
set -x
253-
tar xf $(find . -name "swift-wasm-*.tar.gz" -type f)
254-
echo "TOOLCHAIN=$(find "$PWD" -name "swift-wasm-*" -type d)" >> $GITHUB_ENV
255-
- name: Build hello.wasm
256-
shell: bash
257-
run: |
258-
echo 'print("Hello, world!")' > hello.swift
259-
$TOOLCHAIN/usr/bin/swiftc \
260-
-target wasm32-unknown-wasi \
261-
-sdk $TOOLCHAIN/usr/share/wasi-sysroot \
262-
hello.swift -o hello.wasm && \
263-
echo "Successfully linked hello.wasm"
264-
- name: Test SwiftPM
265-
shell: bash
266-
run: |
267-
set -x
268-
mkdir test
269-
cd test
270-
$TOOLCHAIN/usr/bin/swift package init
271-
$TOOLCHAIN/usr/bin/swift build --triple wasm32-unknown-wasi
272-
- name: Upload hello.wasm compiled with Ubuntu 20.04 package
273-
uses: actions/upload-artifact@v1
274-
with:
275-
name: ubuntu20.04-hello.wasm
276-
path: hello.wasm
277-
- name: Checkout integration-tests
278-
uses: actions/checkout@v2
279-
with:
280-
repository: swiftwasm/integration-tests
281-
path: integration-tests
282-
- name: Run integration tests
283-
run: swift run # Use TOOLCHAIN env value
284-
working-directory: ${{ github.workspace }}/integration-tests

0 commit comments

Comments
 (0)