Skip to content

Commit 5eadd67

Browse files
Migrate CI to GitHub actions (#67)
1 parent c202f07 commit 5eadd67

File tree

14 files changed

+6359
-291
lines changed

14 files changed

+6359
-291
lines changed

.cargo/config.toml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[target.aarch64-unknown-linux-gnu]
2+
linker = "aarch64-linux-gnu-gcc"

.github/pull_request_template.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Closes #[issue number]
2+
3+
<!-- description of the changes -->
4+
5+
- [ ] add entry to the changelog

.github/workflows/release.yml

+132
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
release_tag:
7+
description: 'The version to release starting with `v`'
8+
required: true
9+
type: string
10+
11+
release_ref:
12+
description: 'The branch, tag or SHA to checkout (default to latest)'
13+
default: ''
14+
type: string
15+
16+
jobs:
17+
create-release:
18+
name: Create release
19+
runs-on: ubuntu-latest
20+
21+
outputs:
22+
upload_url: ${{ steps.create_release.outputs.upload_url }}
23+
24+
steps:
25+
- uses: actions/checkout@v3
26+
27+
- name: Create tag
28+
run: |
29+
if [ ! $(git tag -l ${{ inputs.release_tag }}) ]; then
30+
git tag ${{ inputs.release_tag }}
31+
git push origin ${{ inputs.release_tag }}
32+
fi
33+
34+
- name: Create release
35+
id: create_release
36+
uses: actions/create-release@v1
37+
env:
38+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39+
with:
40+
tag_name: ${{ inputs.release_tag }}
41+
release_name: ${{ inputs.release_tag }}
42+
draft: false
43+
44+
build:
45+
needs: create-release
46+
47+
strategy:
48+
fail-fast: false
49+
matrix:
50+
include:
51+
- os: windows-latest
52+
artifact-name: darklua-windows-x86_64
53+
cargo-target: x86_64-pc-windows-msvc
54+
55+
- os: ubuntu-18.04
56+
artifact-name: darklua-linux-x86_64
57+
cargo-target: x86_64-unknown-linux-gnu
58+
59+
- os: ubuntu-18.04
60+
artifact-name: darklua-linux-aarch64
61+
cargo-target: aarch64-unknown-linux-gnu
62+
linker: gcc-aarch64-linux-gnu
63+
64+
- os: macos-latest
65+
artifact-name: darklua-macos-x86_64
66+
cargo-target: x86_64-apple-darwin
67+
68+
- os: macos-latest
69+
artifact-name: darklua-macos-aarch64
70+
cargo-target: aarch64-apple-darwin
71+
72+
name: Build darklua (${{ matrix.artifact-name }})
73+
runs-on: ${{ matrix.os }}
74+
75+
steps:
76+
- uses: actions/checkout@v3
77+
with:
78+
ref: ${{ inputs.release_ref }}
79+
80+
- name: Install Rust
81+
uses: actions-rs/toolchain@v1
82+
with:
83+
toolchain: stable
84+
target: ${{ matrix.cargo-target }}
85+
override: true
86+
profile: minimal
87+
88+
- name: Install linker
89+
if: ${{ matrix.linker != '' }}
90+
run: |
91+
sudo apt update
92+
sudo apt install ${{ matrix.linker }}
93+
if [ ! -f ".cargo/config.toml" ]; then
94+
mkdir .cargo
95+
echo "[target.aarch64-unknown-linux-gnu]" > .cargo/config.toml
96+
echo 'linker = "aarch64-linux-gnu-gcc"' >> .cargo/config.toml
97+
fi
98+
99+
- name: Build darklua binary
100+
run: cargo build --locked --release --target ${{ matrix.cargo-target }}
101+
env:
102+
CARGO_TARGET_DIR: output
103+
104+
- name: Setup archive
105+
shell: bash
106+
run: |
107+
mkdir -p staging
108+
if [ "${{ matrix.os }}" = "windows-latest" ]; then
109+
cp "output/${{ matrix.cargo-target }}/release/darklua.exe" staging/
110+
cd staging
111+
7z a ../release.zip *
112+
else
113+
cp "output/${{ matrix.cargo-target }}/release/darklua" staging/
114+
cd staging
115+
zip ../release.zip *
116+
fi
117+
118+
- name: Upload archive
119+
uses: actions/upload-artifact@v3
120+
with:
121+
name: ${{ matrix.artifact-name }}
122+
path: release.zip
123+
124+
- name: Upload Binary to Release
125+
uses: actions/upload-release-asset@v1
126+
env:
127+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
128+
with:
129+
upload_url: ${{ needs.create-release.outputs.upload_url }}
130+
asset_path: release.zip
131+
asset_name: ${{ matrix.artifact-name }}.zip
132+
asset_content_type: application/zip

.github/workflows/site.yml

+102
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
name: Site
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
jobs:
12+
build-site:
13+
name: Build darklua site
14+
runs-on: ubuntu-latest
15+
defaults:
16+
run:
17+
shell: bash
18+
working-directory: site
19+
20+
steps:
21+
- uses: actions/checkout@v3
22+
23+
- uses: actions/setup-node@v3
24+
with:
25+
node-version: 16
26+
cache: "npm"
27+
cache-dependency-path: "site/package-lock.json"
28+
29+
- name: Install dependencies
30+
run: npm install
31+
32+
- name: Verify code style
33+
run: npm run style-check
34+
35+
- uses: jetli/wasm-pack-action@v0.3.0
36+
with:
37+
version: "latest"
38+
39+
- uses: actions/cache@v3
40+
with:
41+
path: |
42+
~/.cargo/bin/
43+
~/.cargo/registry/index/
44+
~/.cargo/registry/cache/
45+
~/.cargo/git/db/
46+
site/darklua-wasm/target/
47+
key: ${{ runner.os }}-cargo-wasm-${{ hashFiles('**/Cargo.lock') }}
48+
49+
- name: Build darklua-wasm for Node
50+
run: |
51+
wasm-pack -V
52+
wasm-pack build darklua-wasm -t nodejs -d pkg
53+
54+
- name: Install JavaScript wasm tests dependencies
55+
working-directory: site/darklua-wasm/javascript-tests
56+
run: npm install
57+
58+
- name: Run JavaScript wasm tests dependencies
59+
working-directory: site/darklua-wasm/javascript-tests
60+
run: npm run test
61+
62+
- name: Build darklua-wasm (release)
63+
run: |
64+
mv darklua-wasm/pkg darklua-wasm/node-pkg
65+
wasm-pack build darklua-wasm -t bundler --release
66+
67+
- uses: actions/cache@v3
68+
if: github.ref != 'refs/heads/main'
69+
with:
70+
path: |
71+
site/public/
72+
site/.cache/
73+
key: ${{ runner.os }}-gatsby-build-${{ hashFiles('site/package-lock.json') }}
74+
75+
- name: Build site
76+
run: |
77+
npx gatsby --version
78+
npx gatsby build
79+
80+
- name: Archive site
81+
uses: actions/upload-pages-artifact@v1
82+
with:
83+
path: site/public
84+
85+
deploy:
86+
name: Deploy darklua site
87+
runs-on: ubuntu-latest
88+
needs: build-site
89+
if: github.ref == 'refs/heads/main'
90+
91+
environment:
92+
name: github-pages
93+
url: ${{ steps.deployment.outputs.page_url }}
94+
95+
permissions:
96+
pages: write
97+
id-token: write
98+
99+
steps:
100+
- name: Deploy site to GitHub Pages
101+
id: deployment
102+
uses: actions/deploy-pages@v1

.github/workflows/test.yml

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
jobs:
12+
test-release:
13+
name: Run integration tests
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- uses: actions/checkout@v3
18+
19+
- uses: actions/cache@v3
20+
with:
21+
path: |
22+
~/.cargo/bin/
23+
~/.cargo/registry/index/
24+
~/.cargo/registry/cache/
25+
~/.cargo/git/db/
26+
target/
27+
key: ${{ runner.os }}-cargo-release-${{ hashFiles('**/Cargo.lock') }}
28+
29+
- name: Run tests (release)
30+
run: cargo test --locked --release
31+
32+
- name: Build darklua (release)
33+
run: cargo build --release
34+
35+
- name: Setup Lua
36+
uses: leafo/gh-actions-lua@v9
37+
with:
38+
luaVersion: "5.1.5"
39+
40+
- name: Install Lua package manager
41+
uses: leafo/gh-actions-luarocks@v4
42+
43+
- name: Install Lua dependencies
44+
run: |
45+
luarocks install luafilesystem
46+
luarocks install busted
47+
luarocks install luacheck
48+
49+
- name: Run end-to-end tests
50+
run: lua ./scripts/test-commands.lua
51+
52+
test:
53+
name: Run tests
54+
runs-on: ubuntu-latest
55+
56+
steps:
57+
- uses: actions/checkout@v3
58+
59+
- uses: actions/cache@v3
60+
with:
61+
path: |
62+
~/.cargo/bin/
63+
~/.cargo/registry/index/
64+
~/.cargo/registry/cache/
65+
~/.cargo/git/db/
66+
target/
67+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
68+
69+
- name: Run clippy
70+
run: cargo clippy -- -D warnings
71+
72+
- name: Run tests
73+
run: cargo test --locked
74+
75+
code-style:
76+
name: Verify code style
77+
runs-on: ubuntu-latest
78+
79+
steps:
80+
- uses: actions/checkout@v3
81+
82+
- name: Verify code format
83+
run: cargo fmt -- --check

0 commit comments

Comments
 (0)