From 9d58318c2c21625df3a18175cf822147c10194b8 Mon Sep 17 00:00:00 2001 From: xml Date: Wed, 10 Apr 2024 14:07:10 +0800 Subject: [PATCH] test action --- .github/workflows/rust.yml | 72 ++++++++++++++++++++++++++++++++++---- 1 file changed, 65 insertions(+), 7 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index d54fa2f..848d304 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -10,13 +10,71 @@ env: CARGO_TERM_COLOR: always jobs: - build: - + build_job: + # The host should always be linux runs-on: ubuntu-latest + name: Build on ${{ matrix.distro }} ${{ matrix.arch }} + # Run steps on a matrix of 4 arch/distro combinations + strategy: + matrix: + include: + - arch: aarch64 + distro: bullseye steps: - - uses: actions/checkout@v3 - - name: Build - run: cargo build --verbose - - name: Run tests - run: cargo test --verbose + - uses: actions/checkout@v4 + - uses: uraimo/run-on-arch-action@v2 + name: Build result + id: build + with: + arch: ${{ matrix.arch }} + distro: ${{ matrix.distro }} + + # Not required, but speeds up builds + githubToken: ${{ github.token }} + + # Create an result directory + setup: | + echo "pwd=${PWD}" + mkdir -p "${PWD}/result" + + # Mount the result directory as /result in the container + dockerRunArgs: | + --volume "${PWD}/result:/result" + --volume "${GITHUB_WORKSPACE}/system-monitor:/system-monitor" + + # Pass some environment variables to the container + env: | # YAML, but pipe character is necessary + result_name: system-monitor-${{ matrix.distro }}_${{ matrix.arch }} + + # The shell to run commands with in the container + shell: /bin/bash + + # Install some dependencies in the container. This speeds up builds if + # you are also using githubToken. Any dependencies installed here will + # be part of the container image that gets cached, so subsequent + # builds don't have to re-install them. The image layer is cached + # publicly in your project's package repository, so it is vital that + # no secrets are present in the container state or logs. + install: | + case "${{ matrix.distro }}" in + ubuntu*|jessie|stretch|buster|bullseye) + apt-get update -q -y + apt-get install -q -y curl + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | bash -s -- -y + . "${HOME}/.cargo/env" + ;; + esac + + # Produce a binary result and place it in the mounted volume + run: | + . "${HOME}/.cargo/env" + cd /system-monitor + cargo build --release + cp "${PWD}/target/release/system-monitor" "/result/${result_name}" + + - name: Show the result + # Items placed in /result in the container will be in + # ${PWD}/result on the host. + run: | + ls -al "${PWD}/result"