Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: build without cross #80

Merged
merged 15 commits into from
Oct 16, 2023
20 changes: 11 additions & 9 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,15 @@ runs:
if: inputs.arch == 'aarch64'
shell: bash
run: rustup target add $CARGO_BUILD_TARGET
- name: Install Cross
if: inputs.arch == 'aarch64' && inputs.os == 'ubuntu-latest'
uses: taiki-e/install-action@v2
with:
tool: cross
- name: Use Cross
if: inputs.arch == 'aarch64' && inputs.os == 'ubuntu-latest'
- name: Cross Compile Dependencies (Linux)
if: inputs.arch == 'aarch64' && startsWith(inputs.os, 'ubuntu')
shell: bash
run: echo "CARGO=cross" >> $GITHUB_ENV

run: |
sudo apt-get update
sudo apt-get install -y \
gcc-aarch64-linux-gnu \
libc6-dev-arm64-cross
echo "CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
echo "AR_aarch64_unknown_linux_gnu=aarch64-linux-gnu-ar" >> $GITHUB_ENV
echo "CFLAGS_aarch64_unknown_linux_gnu=--sysroot=/usr/aarch64-linux-gnu" >> $GITHUB_ENV
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
13 changes: 7 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ defaults:
jobs:
build:
name: Build and Test
needs: lint
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
Expand All @@ -54,20 +53,22 @@ jobs:
os: ${{ matrix.os }}
arch: ${{ matrix.arch }}
- name: Lint (clippy)
if: matrix.arch == 'x86_64'
run: |
cargo clippy --all-targets --all-features -- -D warnings
- name: Lint (rustfmt)
if: matrix.arch == 'x86_64'
run: |
cargo fmt --all -- --check
- name: Build (maa-cli)
run: |
cargo build --package maa-cli --locked
- name: Test (maa-cli)
if: matrix.arch == 'x86_64' || matrix.os == 'ubuntu-latest'
if: matrix.arch == 'x86_64'
run: |
cargo test --package maa-cli --locked
- name: Test (maa-cli, no-default-features)
if: matrix.arch == 'x86_64' || matrix.os == 'ubuntu-latest'
if: matrix.arch == 'x86_64'
run: |
cargo test --package maa-cli --no-default-features --locked
- name: Install MaaCore
Expand All @@ -80,12 +81,12 @@ jobs:
if: matrix.arch == 'x86_64'
run: |
MAA_CORE_DIR="$(cargo run -- dir lib)"
MAA_RESOURCE_DIR="$(cargo run -- dir resource)
MAA_RESOURCE_DIR="$(cargo run -- dir resource)"
ls -l "$MAA_CORE_DIR"
ls -l "$MAA_RESOURCE_DIR"
echo "MAA_CORE_DIR=$MAA_CORE_DIR" >> $GITHUB_ENV
echo "MAA_RESOURCE_DIR=$RESOURCE_DIR" >> $GITHUB_ENV
- name: Test (maa-sys, static)
echo "MAA_RESOURCE_DIR=$MAA_RESOURCE_DIR" >> $GITHUB_ENV
- name: Test (maa-sys)
# It seems rust needs a static library to check the linking.
# Without this, we can not build maa-sys on Windows.
# https://stackoverflow.com/questions/63394094/rust-linker-seeks-a-lib-rather-than-a-dll
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,15 @@ jobs:
arch: ${{ matrix.arch }}
- name: Build
run: |
$CARGO_CMD build --release --locked --package maa-cli
cd "target/$CARGO_BUILD_TARGET/release"
tar -cvf "$CARGO_BUILD_TARGET.tar" maa
cargo build --release --locked --package maa-cli
- name: Tar Artifact
run: |
tar -cvf "$CARGO_BUILD_TARGET.tar" -C target/$CARGO_BUILD_TARGET/release maa
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: maa_cli-${{ env.CARGO_BUILD_TARGET }}
path: target/${{ env.CARGO_BUILD_TARGET }}/release/*.tar
path: ${{ env.CARGO_BUILD_TARGET }}.tar
retention-days: 1
if-no-files-found: error

Expand Down