Skip to content

Commit 39cb3ec

Browse files
committed
add CI/CD workflows
Signed-off-by: Joel Dice <[email protected]>
1 parent e07bf05 commit 39cb3ec

File tree

10 files changed

+647
-1
lines changed

10 files changed

+647
-1
lines changed

.github/workflows/release.yaml

Lines changed: 224 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,224 @@
1+
name: Release
2+
on:
3+
push:
4+
tags:
5+
- "v*"
6+
workflow_dispatch:
7+
8+
env:
9+
CARGO_TERM_COLOR: always
10+
11+
jobs:
12+
cpython:
13+
name: Build CPython
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v3
17+
18+
- name: Setup WASI-SDK
19+
shell: bash
20+
run: |
21+
cd /tmp
22+
wget https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-16/wasi-sdk-16.0-linux.tar.gz
23+
tar -xf wasi-sdk-16.0-linux.tar.gz
24+
cp -r wasi-sdk-16.0 /opt/wasi-sdk
25+
26+
- name: Build CPython
27+
shell: bash
28+
run: |
29+
git submodule update --init --recursive
30+
mkdir -p cpython/builddir/wasi
31+
mkdir -p cpython/builddir/build
32+
cd cpython/builddir/build
33+
../../configure --prefix=$(pwd)/install --enable-optimizations
34+
make
35+
cd ../wasi
36+
CONFIG_SITE=../../Tools/wasm/config.site-wasm32-wasi ../../Tools/wasm/wasi-env \
37+
../../configure -C --host=wasm32-unknown-wasi --build=$(../../config.guess) \
38+
--with-build-python=$(pwd)/../build/python --prefix=$(pwd)/install --disable-test-modules
39+
make
40+
make install
41+
cd ../../..
42+
43+
- name: Publish CPython
44+
uses: actions/upload-artifact@v3
45+
with:
46+
name: cpython-wasi
47+
path: |
48+
cpython/builddir/wasi
49+
!cpython/builddir/wasi/**/*.pyc
50+
!cpython/builddir/wasi/**/*.whl
51+
!cpython/builddir/wasi/**/Makefile
52+
!cpython/builddir/wasi/**/Changelog
53+
!cpython/builddir/wasi/**/NEWS.txt
54+
55+
release:
56+
name: Build spin-python
57+
needs: cpython
58+
runs-on: ${{ matrix.config.os }}
59+
strategy:
60+
fail-fast: false
61+
matrix:
62+
config:
63+
- {
64+
os: "ubuntu-latest",
65+
arch: "amd64",
66+
wasiSDK: "linux",
67+
extension: "",
68+
buildArgs: "",
69+
target: "",
70+
targetDir: "target/release",
71+
}
72+
- {
73+
os: "ubuntu-latest",
74+
arch: "aarch64",
75+
wasiSDK: "linux",
76+
extension: "",
77+
buildArgs: "\"--target aarch64-unknown-linux-gnu\"",
78+
target: "aarch64-unknown-linux-gnu",
79+
targetDir: "target/aarch64-unknown-linux-gnu/release",
80+
}
81+
- {
82+
os: "macos-latest",
83+
arch: "amd64",
84+
wasiSDK: "macos",
85+
extension: "",
86+
buildArgs: "",
87+
target: "",
88+
targetDir: "target/release",
89+
}
90+
- {
91+
os: "macos-latest",
92+
arch: "aarch64",
93+
wasiSDK: "macos",
94+
extension: "",
95+
buildArgs: "\"--target aarch64-apple-darwin\"",
96+
target: "aarch64-apple-darwin",
97+
targetDir: "target/aarch64-apple-darwin/release/",
98+
}
99+
- {
100+
os: "windows-latest",
101+
arch: "amd64",
102+
wasiSDK: "",
103+
extension: ".exe",
104+
buildArgs: "",
105+
target: "",
106+
targetDir: "target/release",
107+
}
108+
steps:
109+
- uses: actions/checkout@v3
110+
- name: Install latest Rust stable toolchain
111+
uses: actions-rs/toolchain@v1
112+
with:
113+
toolchain: stable
114+
default: true
115+
target: ${{ matrix.config.target }}
116+
117+
- name: set the release version (tag)
118+
if: startsWith(github.ref, 'refs/tags/v')
119+
shell: bash
120+
run: echo "RELEASE_VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
121+
122+
- name: set the release version (main)
123+
if: github.ref == 'refs/heads/main'
124+
shell: bash
125+
run: echo "RELEASE_VERSION=canary" >> $GITHUB_ENV
126+
127+
- name: lowercase the runner OS name
128+
shell: bash
129+
run: |
130+
OS=$(echo "${{ runner.os }}" | tr '[:upper:]' '[:lower:]')
131+
echo "RUNNER_OS=$OS" >> $GITHUB_ENV
132+
133+
- name: "Install Wasm Rust target"
134+
shell: bash
135+
run: rustup target add wasm32-wasi
136+
137+
- name: Setup WASI-SDK
138+
if: runner.os != 'Windows'
139+
shell: bash
140+
run: |
141+
cd /tmp
142+
curl -LO https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-16/wasi-sdk-16.0-${{ matrix.config.wasiSDK }}.tar.gz
143+
tar -xf wasi-sdk-16.0-${{ matrix.config.wasiSDK }}.tar.gz
144+
145+
sudo mv wasi-sdk-16.0 /opt/wasi-sdk
146+
147+
- name: Setup WASI-SDK on Windows
148+
if: runner.os == 'Windows'
149+
shell: bash
150+
run: |
151+
curl -LO https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-16/wasi-sdk-16.0-mingw.tar.gz
152+
tar -xf wasi-sdk-16.0-mingw.tar.gz
153+
154+
- name: Download CPython
155+
uses: actions/download-artifact@v3
156+
with:
157+
name: cpython-wasi
158+
path: cpython/builddir/wasi
159+
160+
- name: setup for cross-compiled linux aarch64 build
161+
if: matrix.config.target == 'aarch64-unknown-linux-gnu'
162+
run: |
163+
sudo apt update
164+
sudo apt install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
165+
echo '[target.aarch64-unknown-linux-gnu]' >> ${HOME}/.cargo/config.toml
166+
echo 'linker = "aarch64-linux-gnu-gcc"' >> ${HOME}/.cargo/config.toml
167+
168+
- name: Build spin-python
169+
shell: bash
170+
run: |
171+
if [ "${{ runner.os}}" == "Windows" ]; then
172+
export WASI_SDK_PATH="$(cygpath -w $(pwd)/wasi-sdk-16.0)"
173+
fi
174+
make BUILD_TARGET=${{ matrix.config.buildArgs }}
175+
176+
- name: Package as plugins tar
177+
shell: bash
178+
run: |
179+
mkdir -v _dist
180+
cp ${{ matrix.config.targetDir }}/spin-python${{ matrix.config.extension }} _dist/py2wasm${{ matrix.config.extension }}
181+
cp LICENSE _dist/py2wasm.license
182+
cd _dist
183+
tar czf py2wasm-${{ env.RELEASE_VERSION }}-${{ env.RUNNER_OS }}-${{ matrix.config.arch }}.tar.gz py2wasm.license py2wasm${{ matrix.config.extension }}
184+
185+
- name: Upload build artifact
186+
uses: actions/upload-artifact@v3
187+
with:
188+
name: py2wasm-${{ env.RELEASE_VERSION }}-${{ env.RUNNER_OS }}-${{ matrix.config.arch }}.tar.gz
189+
path: _dist/py2wasm-${{ env.RELEASE_VERSION }}-${{ env.RUNNER_OS }}-${{ matrix.config.arch }}.tar.gz
190+
191+
- name: upload binary to Github release
192+
if: startsWith(github.ref, 'refs/tags/v')
193+
uses: svenstaro/upload-release-action@v2
194+
with:
195+
repo_token: ${{ secrets.GITHUB_TOKEN }}
196+
file: _dist/py2wasm-${{ env.RELEASE_VERSION }}-${{ env.RUNNER_OS }}-${{ matrix.config.arch }}.tar.gz
197+
tag: ${{ github.ref }}
198+
199+
checksums:
200+
name: generate checksums
201+
runs-on: ubuntu-latest
202+
needs: release
203+
steps:
204+
205+
- name: set the release version (tag)
206+
if: startsWith(github.ref, 'refs/tags/v')
207+
shell: bash
208+
run: echo "RELEASE_VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
209+
210+
- name: download release assets
211+
uses: actions/download-artifact@v3
212+
213+
- name: generate checksums
214+
run: |
215+
ls -lh
216+
sha256sum py2wasm*.tar.gz/py2wasm*.tar.gz > checksums-${{ env.RELEASE_VERSION }}.txt
217+
218+
- name: upload checksums to Github release
219+
if: startsWith(github.ref, 'refs/tags/v')
220+
uses: svenstaro/upload-release-action@v2
221+
with:
222+
repo_token: ${{ secrets.GITHUB_TOKEN }}
223+
file: checksums-${{ env.RELEASE_VERSION }}.txt
224+
tag: ${{ github.ref }}

.github/workflows/test.yaml

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: Test
2+
on:
3+
push:
4+
branches: [main]
5+
pull_request:
6+
branches: [main]
7+
paths-ignore:
8+
- "examples/**"
9+
- "README.md"
10+
- "release-process.md"
11+
- "templates/**"
12+
workflow_dispatch:
13+
14+
env:
15+
CARGO_TERM_COLOR: always
16+
17+
jobs:
18+
test:
19+
name: Test
20+
runs-on: "ubuntu-latest"
21+
steps:
22+
- uses: actions/checkout@v3
23+
- name: Install latest Rust stable toolchain
24+
uses: actions-rs/toolchain@v1
25+
with:
26+
toolchain: stable
27+
default: true
28+
components: clippy, rustfmt
29+
30+
- name: Cache CPython
31+
id: cache-cpython-wasi
32+
uses: actions/cache@v3
33+
with:
34+
path: cpython/builddir/wasi
35+
key: ${{ runner.os }}-cpython-wasi
36+
37+
- uses: Swatinem/rust-cache@v2
38+
with:
39+
shared-key: "${{ runner.os }}-lint-${{ hashFiles('./Cargo.lock') }}"
40+
cache-on-failure: "true"
41+
42+
- name: "Install Wasm Rust target"
43+
shell: bash
44+
run: rustup target add wasm32-wasi
45+
46+
- name: Setup WASI-SDK
47+
shell: bash
48+
run: |
49+
cd /tmp
50+
wget https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-16/wasi-sdk-16.0-linux.tar.gz
51+
tar -xf wasi-sdk-16.0-linux.tar.gz
52+
cp -r wasi-sdk-16.0 /opt/wasi-sdk
53+
54+
- name: Build CPython
55+
if: steps.cache-cpython-wasi.outputs.cache-hit != 'true'
56+
shell: bash
57+
run: |
58+
git submodule update --init --recursive
59+
mkdir -p cpython/builddir/wasi
60+
mkdir -p cpython/builddir/build
61+
cd cpython/builddir/build
62+
../../configure --prefix=$(pwd)/install --enable-optimizations
63+
make
64+
cd ../wasi
65+
CONFIG_SITE=../../Tools/wasm/config.site-wasm32-wasi ../../Tools/wasm/wasi-env \
66+
../../configure -C --host=wasm32-unknown-wasi --build=$(../../config.guess) \
67+
--with-build-python=$(pwd)/../build/python --prefix=$(pwd)/install --disable-test-modules
68+
make
69+
make install
70+
cd ../../..
71+
72+
- name: Build spin-python-engine
73+
shell: bash
74+
run: make
75+
76+
- name: Install spin
77+
uses: engineerd/[email protected]
78+
with:
79+
name: "spin"
80+
url: "https://github.com/fermyon/spin/releases/download/v0.8.0/spin-v0.8.0-linux-amd64.tar.gz"
81+
pathInArchive: "spin"
82+
83+
- name: Install pipenv
84+
shell: bash
85+
run: python3 -m pip install --user pipenv
86+
87+
- name: Run Test
88+
shell: bash
89+
run: |
90+
cd test
91+
./test.sh

0 commit comments

Comments
 (0)