Skip to content

Commit cdd8db1

Browse files
authored
Merge pull request #1811 from swiftwasm/maxd/ubuntu-20.04
Build for Ubuntu 20.04 on CI
2 parents 2b3f2a9 + 237ecfb commit cdd8db1

File tree

4 files changed

+137
-28
lines changed

4 files changed

+137
-28
lines changed

.github/workflows/main.yml

+98-14
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ on:
1111
- swiftwasm-release/5.3
1212

1313
jobs:
14-
linux_build:
14+
ubuntu1804_build:
1515
timeout-minutes: 0
1616
runs-on: ubuntu-18.04
1717

@@ -39,17 +39,63 @@ jobs:
3939
- uses: actions/cache@v1
4040
with:
4141
path: ../build-cache
42-
key: ${{ runner.os }}-sccache-v10-${{ steps.cache_timestamp.outputs.timestamp }}
42+
key: ubuntu-18.04-sccache-v10-${{ steps.cache_timestamp.outputs.timestamp }}
4343
restore-keys: |
44-
${{ runner.os }}-sccache-v10-
45-
- name: Build Linux installable archive
44+
ubuntu-18.04-sccache-v10-
45+
- name: Build Ubuntu 18.04 installable archive
4646
run: |
4747
./utils/webassembly/ci.sh
48-
- name: Upload Linux installable archive
48+
- name: Upload Ubuntu 18.04 installable archive
4949
uses: actions/upload-artifact@v1
5050
with:
51-
name: linux-installable
52-
path: ../swift-wasm-DEVELOPMENT-SNAPSHOT-linux.tar.gz
51+
name: ubuntu18.04-installable
52+
path: ../swift-wasm-DEVELOPMENT-SNAPSHOT-ubuntu18.04.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
60+
61+
ubuntu2004_build:
62+
timeout-minutes: 0
63+
runs-on: ubuntu-20.04
64+
65+
steps:
66+
- name: Free disk space
67+
run: |
68+
df -h
69+
sudo swapoff -a
70+
sudo rm -f /swapfile
71+
sudo rm -rf /opt/hostedtoolcache
72+
sudo rm -rf /usr/share/dotnet
73+
sudo apt clean
74+
docker rmi $(docker image ls -aq)
75+
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.tar.gz
5399
# - name: Pack test results
54100
# run: tar cJf swift-test-results.tar.gz ../build/*/swift-linux-x86_64/swift-test-results
55101
# - name: Upload test results
@@ -94,6 +140,7 @@ jobs:
94140
with:
95141
name: macos-test-results
96142
path: ./swift-test-results.tar.gz
143+
97144
macos_smoke_test:
98145
name: Run smoke tests on macOS
99146
runs-on: macos-latest
@@ -129,15 +176,16 @@ jobs:
129176
with:
130177
name: macos-hello.wasm
131178
path: hello.wasm
132-
linux_smoke_test:
133-
name: Run smoke tests on Linux
179+
180+
ubuntu1804_smoke_test:
181+
name: Run smoke tests on Ubuntu 18.04
134182
runs-on: ubuntu-18.04
135-
needs: linux_build
183+
needs: ubuntu1804_build
136184
steps:
137-
- name: Download installable Linux archive
185+
- name: Download installable Ubuntu 18.04 archive
138186
uses: actions/download-artifact@v1
139187
with:
140-
name: linux-installable
188+
name: ubuntu18.04-installable
141189
- name: Build hello.wasm
142190
shell: bash
143191
run: |
@@ -159,8 +207,44 @@ jobs:
159207
cd test
160208
$TOOLCHAIN_PATH/usr/bin/swift package init
161209
$TOOLCHAIN_PATH/usr/bin/swift build --triple wasm32-unknown-wasi
162-
- name: Upload hello.wasm compiled with Linux package
210+
- name: Upload hello.wasm compiled with Ubuntu 18.04 package
163211
uses: actions/upload-artifact@v1
164212
with:
165-
name: linux-hello.wasm
213+
name: ubuntu18.04-hello.wasm
166214
path: hello.wasm
215+
216+
ubuntu2004_smoke_test:
217+
name: Run smoke tests on Ubuntu 20.04
218+
runs-on: ubuntu-20.04
219+
needs: ubuntu2004_build
220+
steps:
221+
- name: Download installable Ubuntu 20.04 archive
222+
uses: actions/download-artifact@v1
223+
with:
224+
name: ubuntu20.04-installable
225+
- name: Build hello.wasm
226+
shell: bash
227+
run: |
228+
set -x
229+
tar xf $(find . -name "swift-wasm-*.tar.gz" -type f)
230+
TOOLCHAIN_PATH=$(find "$PWD" -name "swift-wasm-*" -type d)
231+
echo 'print("Hello, world!")' > hello.swift
232+
$TOOLCHAIN_PATH/usr/bin/swiftc \
233+
-target wasm32-unknown-wasi \
234+
-sdk $TOOLCHAIN_PATH/usr/share/wasi-sysroot \
235+
hello.swift -o hello.wasm && \
236+
echo "Successfully linked hello.wasm"
237+
- name: Test SwiftPM
238+
shell: bash
239+
run: |
240+
set -x
241+
TOOLCHAIN_PATH=$(find "$PWD" -name "swift-wasm-*" -type d)
242+
mkdir test
243+
cd test
244+
$TOOLCHAIN_PATH/usr/bin/swift package init
245+
$TOOLCHAIN_PATH/usr/bin/swift build --triple wasm32-unknown-wasi
246+
- name: Upload hello.wasm compiled with Ubuntu 20.04 package
247+
uses: actions/upload-artifact@v1
248+
with:
249+
name: ubuntu2004-hello.wasm
250+
path: hello.wasm

utils/webassembly/build-toolchain.sh

+8-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,14 @@ case $(uname -s) in
1414
HOST_SUFFIX=macosx-x86_64
1515
;;
1616
Linux)
17-
OS_SUFFIX=linux
17+
if [ $(grep RELEASE /etc/lsb-release) == "DISTRIB_RELEASE=18.04" ]; then
18+
OS_SUFFIX=ubuntu18.04
19+
elif [ $(grep RELEASE /etc/lsb-release) == "DISTRIB_RELEASE=20.04" ]; then
20+
OS_SUFFIX=ubuntu20.04
21+
else
22+
echo "Unknown Ubuntu version"
23+
exit 1
24+
fi
1825
HOST_PRESET=webassembly-linux-host
1926
TARGET_PRESET=webassembly-linux-target
2027
HOST_SUFFIX=linux-x86_64

utils/webassembly/distribute-latest-toolchain.sh

+10-6
Original file line numberDiff line numberDiff line change
@@ -96,25 +96,29 @@ upload_tarball() {
9696

9797
tmp_dir=$(mktemp -d)
9898
pushd $tmp_dir
99-
download_artifact linux-installable
99+
download_artifact ubuntu18.04-installable
100+
download_artifact ubuntu20.04-installable
100101
download_artifact macos-installable
101-
unzip linux-installable.zip
102+
unzip ubuntu18.04-installable.zip
103+
unzip ubuntu20.04-installable.zip
102104
unzip macos-installable.zip
103105

104-
toolchain_name=$(basename $(tar tfz swift-wasm-$2-SNAPSHOT-linux.tar.gz | head -n1))
106+
toolchain_name=$(basename $(tar tfz swift-wasm-$2-SNAPSHOT-ubuntu18.04.tar.gz | head -n1))
105107

106108
if is_released $toolchain_name; then
107109
echo "Latest toolchain $toolchain_name has been already released"
108110
exit 0
109111
fi
110112

111-
cp swift-wasm-$2-SNAPSHOT-linux.tar.gz "$toolchain_name-linux.tar.gz"
112-
cp swift-wasm-$2-SNAPSHOT-osx.tar.gz "$toolchain_name-osx.tar.gz"
113+
mv swift-wasm-$2-SNAPSHOT-ubuntu18.04.tar.gz "$toolchain_name-ubuntu18.04.tar.gz"
114+
mv swift-wasm-$2-SNAPSHOT-ubuntu20.04.tar.gz "$toolchain_name-ubuntu20.04.tar.gz"
115+
mv swift-wasm-$2-SNAPSHOT-osx.tar.gz "$toolchain_name-osx.tar.gz"
113116

114117
create_tag $toolchain_name $head_sha
115118
release_id=$(create_release $toolchain_name $toolchain_name $head_sha)
116119

120+
upload_tarball $release_id "$toolchain_name-ubuntu18.04.tar.gz"
121+
upload_tarball $release_id "$toolchain_name-ubuntu20.04.tar.gz"
117122
upload_tarball $release_id "$toolchain_name-osx.tar.gz"
118-
upload_tarball $release_id "$toolchain_name-linux.tar.gz"
119123

120124
popd

utils/webassembly/linux/install-dependencies.sh

+21-7
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,27 @@
33
set -ex
44

55
sudo apt update
6-
sudo apt install -y \
7-
git ninja-build clang python python-six \
8-
uuid-dev libicu-dev icu-devtools libbsd-dev \
9-
libedit-dev libxml2-dev libsqlite3-dev swig \
10-
libpython-dev libncurses5-dev pkg-config \
11-
libblocksruntime-dev libcurl4-openssl-dev \
12-
systemtap-sdt-dev tzdata rsync wget llvm zip unzip
6+
7+
if [ $(grep RELEASE /etc/lsb-release) == "DISTRIB_RELEASE=18.04" ]; then
8+
sudo apt install -y \
9+
git ninja-build clang python python-six \
10+
uuid-dev libicu-dev icu-devtools libbsd-dev \
11+
libedit-dev libxml2-dev libsqlite3-dev swig \
12+
libpython-dev libncurses5-dev pkg-config \
13+
libblocksruntime-dev libcurl4-openssl-dev \
14+
systemtap-sdt-dev tzdata rsync wget llvm zip unzip
15+
elif [ $(grep RELEASE /etc/lsb-release) == "DISTRIB_RELEASE=20.04" ]; then
16+
sudo apt install -y \
17+
git ninja-build clang python python-six \
18+
uuid-dev libicu-dev icu-devtools libbsd-dev \
19+
libedit-dev libxml2-dev libsqlite3-dev swig \
20+
libpython2-dev libncurses5-dev pkg-config \
21+
libblocksruntime-dev libcurl4-openssl-dev \
22+
systemtap-sdt-dev tzdata rsync wget llvm zip unzip
23+
else
24+
echo "Unknown Ubuntu version"
25+
exit 1
26+
fi
1327
sudo apt clean
1428

1529
SOURCE_PATH="$( cd "$(dirname $0)/../../../.." && pwd )"

0 commit comments

Comments
 (0)