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

workflows/ci: Build statically linked executables where possible #224

Merged
merged 2 commits into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/actions/preload-img-cache/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ runs:
key: e2e-${{ github.sha }}-${{ runner.os }}
fail-on-cache-miss: true
path: |
target/release/e2e
target/release/e2e.exe
target/output/e2e
target/output/e2e.exe

- name: Downloading device image for ${{ inputs.device }}
if: ${{ ! steps.cache-img.outputs.cache-hit }}
shell: sh
working-directory: e2e
run: ../target/release/e2e download --stripped -d ${{ inputs.device }}
run: ../target/output/e2e download --stripped -d ${{ inputs.device }}

- if: ${{ ! steps.cache-img.outputs.cache-hit }}
name: Creating sparse archive from image
Expand Down
6 changes: 3 additions & 3 deletions .github/actions/preload-magisk-cache/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ runs:
key: e2e-${{ github.sha }}-${{ runner.os }}
fail-on-cache-miss: true
path: |
target/release/e2e
target/release/e2e.exe
target/output/e2e
target/output/e2e.exe

- name: Downloading Magisk
if: ${{ ! steps.cache-magisk.outputs.cache-hit }}
shell: sh
working-directory: e2e
run: ../target/release/e2e download --magisk
run: ../target/output/e2e download --magisk
51 changes: 33 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
runs-on: ${{ matrix.os }}
env:
CARGO_TERM_COLOR: always
RUSTFLAGS: -C strip=symbols
RUSTFLAGS: -C strip=symbols -C target-feature=+crt-static
strategy:
fail-fast: false
matrix:
Expand All @@ -40,28 +40,35 @@ jobs:
| sed -E "s/^v//g;s/([^-]*-g)/r\1/;s/-/./g" \
>> "${GITHUB_OUTPUT}"

- name: Get Rust LLVM target triple
- name: Get Rust target triple
id: get_target
shell: bash
env:
RUSTC_BOOTSTRAP: '1'
run: |
echo -n 'name=' >> "${GITHUB_OUTPUT}"
rustc -Z unstable-options --print target-spec-json \
| jq -r '."llvm-target"' \
>> "${GITHUB_OUTPUT}"
rustc -vV | sed -n 's|host: ||p' >> "${GITHUB_OUTPUT}"

- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2

- name: Clippy
run: cargo clippy --release --workspace --features static
shell: bash
run: |
cargo clippy --release --workspace --features static \
--target ${{ steps.get_target.outputs.name }}

- name: Build
run: cargo build --release --workspace --features static
shell: bash
run: |
cargo build --release --workspace --features static \
--target ${{ steps.get_target.outputs.name }}

- name: Tests
run: cargo test --release --workspace --features static
shell: bash
run: |
cargo test --release --workspace --features static \
--target ${{ steps.get_target.outputs.name }}

- name: Archive documentation
uses: actions/upload-artifact@v3
Expand All @@ -71,22 +78,30 @@ jobs:
LICENSE
README.md

# Due to https://github.com/rust-lang/rust/issues/78210, we have to use
# the --target option, which puts all output files in a different path.
# Symlink that path to the normal output directory so that we don't need
# to specify the Rust triple everywhere.
- name: Symlink target directory
run: |
ln -sfn ${{ steps.get_target.outputs.name }}/release target/output

# This is separate so we can have a flat directory structure.
- name: Archive executable
uses: actions/upload-artifact@v3
with:
name: avbroot-${{ steps.get_version.outputs.version }}-${{ steps.get_target.outputs.name }}
path: |
target/release/avbroot
target/release/avbroot.exe
target/output/avbroot
target/output/avbroot.exe

- name: Cache e2e executable
uses: actions/cache@v3
with:
key: e2e-${{ github.sha }}-${{ runner.os }}
path: |
target/release/e2e
target/release/e2e.exe
target/output/e2e
target/output/e2e.exe

setup:
name: Prepare workflow data
Expand All @@ -108,16 +123,16 @@ jobs:
key: e2e-${{ github.sha }}-${{ runner.os }}
fail-on-cache-miss: true
path: |
target/release/e2e
target/release/e2e.exe
target/output/e2e
target/output/e2e.exe

- name: Loading test config
id: load-config
working-directory: e2e
run: |
echo 'config-path=e2e/e2e.toml' >> "${GITHUB_OUTPUT}"
echo -n 'device-list=' >> "${GITHUB_OUTPUT}"
../target/release/e2e list \
../target/output/e2e list \
| jq -cnR '[inputs | select(length > 0)]' \
>> "${GITHUB_OUTPUT}"

Expand Down Expand Up @@ -209,10 +224,10 @@ jobs:
key: e2e-${{ github.sha }}-${{ runner.os }}
fail-on-cache-miss: true
path: |
target/release/e2e
target/release/e2e.exe
target/output/e2e
target/output/e2e.exe

# Finally run tests
- name: Run test for ${{ matrix.device }}
working-directory: e2e
run: ../target/release/e2e test --stripped -d ${{ matrix.device }}
run: ../target/output/e2e test --stripped -d ${{ matrix.device }}