Skip to content

Commit 346ad8e

Browse files
committed
wip: build and tests workflows
1 parent e59081e commit 346ad8e

File tree

2 files changed

+110
-74
lines changed

2 files changed

+110
-74
lines changed

.github/workflows/build.yml

Lines changed: 54 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,70 @@
11
name: Build
22

3-
on: [push]
3+
on: [push, pull_request]
44

55
jobs:
66
build:
7-
runs-on: ubuntu-latest
7+
name: Build - ${{ matrix.os }} (${{ matrix.arch }})
8+
runs-on: ${{ matrix.runner }}
9+
strategy:
10+
matrix:
11+
include:
12+
- os: linux
13+
arch: x86_64
14+
runner: ubuntu-latest
15+
target: x86_64-unknown-linux-gnu
16+
- os: linux
17+
arch: aarch64
18+
runner: ubuntu-latest
19+
target: aarch64-unknown-linux-gnu
20+
- os: windows
21+
arch: x86_64
22+
runner: windows-latest
23+
target: x86_64-pc-windows-msvc
24+
- os: windows
25+
arch: aarch64
26+
runner: windows-latest
27+
target: aarch64-pc-windows-msvc
28+
- os: macos
29+
arch: x86_64
30+
runner: macos-latest
31+
target: x86_64-apple-darwin
32+
- os: macos
33+
arch: aarch64
34+
runner: macos-latest
35+
target: aarch64-apple-darwin
836

937
steps:
1038
- name: Checkout Source
11-
id: checkout-source
12-
uses: actions/checkout@v2
13-
- name: Set variables
14-
id: vars
39+
uses: actions/checkout@v4
40+
41+
- name: Install Rust toolchain
42+
uses: dtolnay/rust-toolchain@stable
43+
with:
44+
targets: ${{ matrix.target }}
45+
46+
- name: Install cross-compilation tools (Linux ARM64)
47+
if: matrix.target == 'aarch64-unknown-linux-gnu'
48+
run: |
49+
sudo apt-get update
50+
sudo apt-get install -y gcc-aarch64-linux-gnu
51+
52+
- name: Configure cross-compilation (Linux ARM64)
53+
if: matrix.target == 'aarch64-unknown-linux-gnu'
1554
run: |
16-
echo "::set-output name=package_name::$(sed -En 's/name[[:space:]]*=[[:space:]]*"([^"]+)"/\1/p' Cargo.toml | head -1)"
17-
echo "::set-output name=package_version::$(sed -En 's/version[[:space:]]*=[[:space:]]*"([^"]+)"/\1/p' Cargo.toml | head -1)"
18-
- run: |
19-
echo "${{steps.vars.outputs.package_name}}"
20-
echo "${{steps.vars.outputs.package_version}}"
21-
- uses: actions/cache@v4.2.0
55+
echo "[target.aarch64-unknown-linux-gnu]" >> ~/.cargo/config.toml
56+
echo "linker = \"aarch64-linux-gnu-gcc\"" >> ~/.cargo/config.toml
57+
58+
- name: Cache cargo registry and build
59+
uses: actions/cache@v4
2260
with:
2361
path: |
2462
~/.cargo/registry
2563
~/.cargo/git
2664
target
27-
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
65+
key: ${{ runner.os }}-${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.lock') }}
66+
restore-keys: |
67+
${{ runner.os }}-${{ matrix.target }}-cargo-
2868
2969
- name: Build
30-
id: build-release
31-
run: cargo build --release
32-
33-
- name: Zip release
34-
id: zip-release
35-
run: zip -j build.zip target/release/ci
36-
37-
- name: Artifact Production
38-
id: create-artifact
39-
uses: actions/upload-artifact@v4
40-
with:
41-
name: build
42-
path: build.zip
43-
44-
- name: Remove Same Release
45-
uses: omarabid-forks/action-rollback@stable
46-
continue-on-error: true
47-
with:
48-
tag: ${{ steps.vars.outputs.package_version }}
49-
env:
50-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51-
52-
- name: Create Release
53-
id: create-release
54-
uses: actions/create-release@latest
55-
env:
56-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
57-
with:
58-
tag_name: ${{steps.vars.outputs.package_version}}
59-
release_name: Version ${{steps.vars.outputs.package_version}}
60-
body: ${{steps.vars.outputs.package_name}} - ${{steps.vars.outputs.package_version}}
61-
draft: false
62-
prerelease: false
63-
64-
- name: Upload Artifact
65-
id: upload-release-asset
66-
uses: actions/upload-release-asset@v1
67-
env:
68-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
69-
with:
70-
upload_url: ${{ steps.create-release.outputs.upload_url }}
71-
asset_path: build.zip
72-
asset_name: build.zip
73-
asset_content_type: application/zip
74-
75-
- uses: omarabid-forks/purge-artifacts@v1
76-
with:
77-
token: ${{ secrets.GITHUB_TOKEN }}
78-
expire-in: 0
70+
run: cargo build --release --target ${{ matrix.target }}

.github/workflows/tests.yml

Lines changed: 56 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,67 @@ on: [push, pull_request]
44

55
jobs:
66
test:
7-
name: ${{ matrix.os }}
8-
runs-on: ${{ matrix.os }}
7+
name: Test - ${{ matrix.os }} (${{ matrix.arch }})
8+
runs-on: ${{ matrix.runner }}
99
strategy:
1010
matrix:
11-
os: [ubuntu-latest]
11+
include:
12+
- os: linux
13+
arch: x86_64
14+
runner: ubuntu-latest
15+
target: x86_64-unknown-linux-gnu
16+
- os: linux
17+
arch: aarch64
18+
runner: ubuntu-latest
19+
target: aarch64-unknown-linux-gnu
20+
- os: windows
21+
arch: x86_64
22+
runner: windows-latest
23+
target: x86_64-pc-windows-msvc
24+
- os: windows
25+
arch: aarch64
26+
runner: windows-latest
27+
target: aarch64-pc-windows-msvc
28+
- os: macos
29+
arch: x86_64
30+
runner: macos-latest
31+
target: x86_64-apple-darwin
32+
- os: macos
33+
arch: aarch64
34+
runner: macos-latest
35+
target: aarch64-apple-darwin
36+
1237
steps:
1338
- name: Checkout sources
14-
uses: actions/checkout@v2
39+
uses: actions/checkout@v4
1540

16-
- name: Install stable toolchain
17-
uses: omarabid-forks/rs-toolchain@v1
41+
- name: Install Rust toolchain
42+
uses: dtolnay/rust-toolchain@stable
1843
with:
19-
profile: minimal
20-
toolchain: stable
21-
override: true
44+
targets: ${{ matrix.target }}
2245

23-
- name: Run cargo test
24-
uses: omarabid-forks/rs-cargo@v1
46+
- name: Install cross-compilation tools (Linux ARM64)
47+
if: matrix.target == 'aarch64-unknown-linux-gnu'
48+
run: |
49+
sudo apt-get update
50+
sudo apt-get install -y gcc-aarch64-linux-gnu
51+
52+
- name: Configure cross-compilation (Linux ARM64)
53+
if: matrix.target == 'aarch64-unknown-linux-gnu'
54+
run: |
55+
echo "[target.aarch64-unknown-linux-gnu]" >> ~/.cargo/config.toml
56+
echo "linker = \"aarch64-linux-gnu-gcc\"" >> ~/.cargo/config.toml
57+
58+
- name: Cache cargo registry and build
59+
uses: actions/cache@v4
2560
with:
26-
command: test
61+
path: |
62+
~/.cargo/registry
63+
~/.cargo/git
64+
target
65+
key: ${{ runner.os }}-${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.lock') }}
66+
restore-keys: |
67+
${{ runner.os }}-${{ matrix.target }}-cargo-
68+
69+
- name: Run cargo test
70+
run: cargo test --target ${{ matrix.target }}

0 commit comments

Comments
 (0)