mirror of
https://github.com/containers/youki
synced 2025-04-21 00:38:02 +02:00
* fix: release ci tests also need apparmor disable Signed-off-by: Yashodhan Joshi <yjdoc2@gmail.com> * fix: filter step should ignore the grep failure it is expected for grep to fail if no matching paths are found Signed-off-by: Yashodhan Joshi <yjdoc2@gmail.com> --------- Signed-off-by: Yashodhan Joshi <yjdoc2@gmail.com>
171 lines
5.9 KiB
YAML
171 lines
5.9 KiB
YAML
name: 🔍 Basic Checks
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
changes:
|
|
runs-on: ubuntu-24.04
|
|
timeout-minutes: 15
|
|
outputs:
|
|
any_modified: ${{ steps.filter.outputs.any_modified }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0 # Required to get full history
|
|
# Using Git commands instead of tj-actions/changed-files
|
|
- name: Get changed files
|
|
id: filter
|
|
run: |
|
|
# grep will exit with non-zero if no matching pattern
|
|
# but we are ok with that, so to prevent workflow failing
|
|
# we set allow errors
|
|
set +e
|
|
|
|
# Change the base commit depending on event type
|
|
if [[ "${{ github.event_name }}" == "push" ]]; then
|
|
# For push events
|
|
if [[ -n "${{ github.event.before }}" ]]; then
|
|
BASE_COMMIT="${{ github.event.before }}"
|
|
else
|
|
# For workflow dispatch, etc.
|
|
git fetch origin main --depth=1
|
|
BASE_COMMIT="origin/main"
|
|
fi
|
|
elif [[ "${{ github.event_name }}" == "pull_request" ]]; then
|
|
# For pull request events
|
|
git fetch origin "${{ github.base_ref }}" --depth=1
|
|
BASE_COMMIT="origin/${{ github.base_ref }}"
|
|
else
|
|
# For workflow dispatch events
|
|
git fetch origin main --depth=1
|
|
BASE_COMMIT="HEAD~1"
|
|
fi
|
|
|
|
echo "Using base commit: $BASE_COMMIT"
|
|
|
|
# Get changed files and filter out the ones to ignore
|
|
ALL_CHANGED_FILES=$(git diff --name-only --diff-filter=ACMRT "$BASE_COMMIT" HEAD)
|
|
FILTERED_FILES=$(echo "$ALL_CHANGED_FILES" | grep -v -E '^docs/|^LICENSE$|\.md$')
|
|
|
|
# Set the results
|
|
if [[ -n "$FILTERED_FILES" ]]; then
|
|
echo "any_modified=true" >> $GITHUB_OUTPUT
|
|
echo "all_modified_files<<EOF" >> $GITHUB_OUTPUT
|
|
echo "$FILTERED_FILES" >> $GITHUB_OUTPUT
|
|
echo "EOF" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "any_modified=false" >> $GITHUB_OUTPUT
|
|
echo "all_modified_files=" >> $GITHUB_OUTPUT
|
|
fi
|
|
- name: List all changed files
|
|
run: |
|
|
if [[ "${{ steps.filter.outputs.any_modified }}" == "true" ]]; then
|
|
echo "Changed files detected:"
|
|
echo "${{ steps.filter.outputs.all_modified_files }}"
|
|
else
|
|
echo "No relevant changes detected"
|
|
fi
|
|
|
|
check:
|
|
needs: [changes]
|
|
if: needs.changes.outputs.any_modified == 'true'
|
|
runs-on: ubuntu-24.04
|
|
timeout-minutes: 15
|
|
strategy:
|
|
matrix:
|
|
arch: [ "x86_64", "aarch64" ]
|
|
libc: [ "gnu", "musl" ]
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Setup Rust toolchain and cache
|
|
uses: actions-rust-lang/setup-rust-toolchain@v1
|
|
with:
|
|
components: clippy
|
|
- name: Install nightly rustfmt
|
|
run: rustup toolchain install nightly --component rustfmt --profile minimal --no-self-update
|
|
- name: typos-action
|
|
uses: crate-ci/typos@v1.22.9
|
|
- name: Install just
|
|
uses: taiki-e/install-action@just
|
|
- name: Install cross-rs
|
|
run: cargo install cross --git https://github.com/cross-rs/cross
|
|
- name: Setup target
|
|
run: |
|
|
echo "CARGO=cross" >> ${GITHUB_ENV}
|
|
echo "TARGET=${{ matrix.arch }}-unknown-linux-${{ matrix.libc }}" >> ${GITHUB_ENV}
|
|
- name: Check formatting and lints
|
|
run: just lint
|
|
- name: Install cargo machete
|
|
uses: taiki-e/install-action@v2
|
|
with:
|
|
tool: cargo-machete@0.7.0
|
|
- name: Check unused deps
|
|
run: cargo machete
|
|
|
|
tests:
|
|
needs: [changes]
|
|
if: needs.changes.outputs.any_modified == 'true'
|
|
runs-on: ubuntu-24.04
|
|
timeout-minutes: 20
|
|
strategy:
|
|
matrix:
|
|
arch: [ "x86_64" ]
|
|
libc: [ "gnu", "musl" ]
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Setup Rust toolchain and cache
|
|
uses: actions-rust-lang/setup-rust-toolchain@v1
|
|
- name: Install just
|
|
uses: taiki-e/install-action@just
|
|
- name: Install cross-rs
|
|
run: cargo install cross --git https://github.com/cross-rs/cross
|
|
- name: Setup target
|
|
run: |
|
|
echo "CARGO=cross" >> ${GITHUB_ENV}
|
|
echo "TARGET=${{ matrix.arch }}-unknown-linux-${{ matrix.libc }}" >> ${GITHUB_ENV}
|
|
- name: Disable AppArmor restrictions
|
|
run: echo 0 | sudo tee /proc/sys/kernel/apparmor_restrict_unprivileged_userns
|
|
- name: Run tests
|
|
run: just test-basic
|
|
- name: Run feature tests
|
|
run: just test-features
|
|
|
|
# We do not yet enforce some minimum coverage, and there were come codecov issues
|
|
# so commenting this out for now. When we are ready to enforce coverage, uncomment
|
|
# and check this works or not.
|
|
# coverage:
|
|
# needs: [changes]
|
|
# if: needs.changes.outputs.any_modified == 'true'
|
|
# runs-on: ubuntu-24.04
|
|
# timeout-minutes: 20
|
|
# name: Run test coverage
|
|
# steps:
|
|
# - uses: actions/checkout@v4
|
|
# - name: Setup Rust toolchain and cache
|
|
# uses: actions-rust-lang/setup-rust-toolchain@v1.3.7
|
|
# - name: Install llvm-tools-preview
|
|
# run: rustup component add llvm-tools-preview
|
|
# - name: install cargo-llvm-cov
|
|
# uses: taiki-e/install-action@v2
|
|
# with:
|
|
# tool: cargo-llvm-cov@0.4.0
|
|
# - uses: taiki-e/install-action@just
|
|
# - name: Install requirements
|
|
# run: sudo env PATH=$PATH just ci-prepare
|
|
# - name: Run Test Coverage for youki
|
|
# run: |
|
|
# cargo llvm-cov clean --workspace
|
|
# cargo llvm-cov --no-report -- --test-threads=1
|
|
# cargo llvm-cov --no-run --lcov --output-path ./coverage.lcov
|
|
# - name: Upload Youki Code Coverage Results
|
|
# uses: codecov/codecov-action@v4
|
|
# with:
|
|
# file: ./coverage.lcov
|