Skip to content

reduce test CI workflow run time #101

reduce test CI workflow run time

reduce test CI workflow run time #101

Workflow file for this run

name: "Test CI"
on:
push:
branches: [main]
paths:
- "**.rs"
- "*.toml"
- "Cargo.lock"
- ".github/workflows/run-dev-tests.yml"
pull_request:
# types: opened
branches: [main]
paths:
- "**.rs"
- "*.toml"
- "Cargo.lock"
- ".github/workflows/run-dev-tests.yml"
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
jobs:
cache-deps:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest]
steps:
- run: rustup update --no-self-update
- uses: actions/checkout@v4
- name: Cache .cargo locked resources
uses: actions/cache@v4
with:
path: ~/.cargo
key: ${{ runner.os }}-test-cargo-${{ hashFiles('Cargo.lock') }}
- run: cargo fetch
- run: rustup component add llvm-tools-preview
- name: Install third-party binaries
uses: taiki-e/install-action@v2
with:
tool: cargo-nextest,cargo-llvm-cov,cargo-binstall,just
- uses: actions/setup-python@v5
with:
python-version: 3.x
- name: Install workflow deps
run: python3 -m pip install meson
- name: Install ninja (Linux)
if: runner.os == 'Linux'
run: sudo apt-get install ninja-build
- name: Install ninja (Windows)
if: runner.os == 'Windows'
run: choco install ninja
- run: just test
# continue-on-error: true
- name: Tar build assets
run: tar -cvf llvm-cov-assets.tar target/llvm-cov-target
- name: save build as artifact
uses: actions/upload-artifact@v4
with:
path: llvm-cov-assets.tar
name: cpp-linter-lib_tests-${{ runner.os }}-${{ github.run_id }}
retention-days: 1
test:
needs: [cache-deps]
name: test ${{ matrix.os }} w/ clang v${{ matrix.version }}
strategy:
fail-fast: false
matrix:
os: ['windows-latest', ubuntu-latest]
version: ['17', '16', '15', '14', '13', '12', '11', '10', '9', '8', '7']
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- run: rustup component add llvm-tools-preview
# https://docs.rs/openssl/latest/openssl/#automatic
# - name: Install OpenSSL (Linux)
# if: runner.os == 'Linux'
# run: sudo apt-get install -y pkg-config libssl-dev
# - name: Install OpenSSL (MacOS)
# if: runner.os == 'macOS'
# run: brew install openssl@3
# - name: Install OpenSSL (Windows)
# if: runner.os == 'Windows'
# run: vcpkg install openssl
- name: Install third-party binaries
uses: taiki-e/install-action@v2
with:
tool: cargo-nextest,cargo-llvm-cov,cargo-binstall,just
- name: Install llvm-cov-pretty (HTML report generator)
run: cargo binstall -y llvm-cov-pretty
- uses: actions/setup-python@v5
with:
python-version: 3.x
- name: Install workflow deps
run: python3 -m pip install meson
# # https://github.com/ninja-build/ninja/wiki/Pre-built-Ninja-packages
- name: Install ninja (Linux)
if: runner.os == 'Linux'
run: sudo apt-get install ninja-build
- name: Install ninja (Windows)
if: runner.os == 'Windows'
run: choco install ninja
- name: Install Linux clang dependencies
if: runner.os == 'Linux'
shell: bash
run: |
sudo apt-get update
# First try installing from default Ubuntu repositories before trying LLVM script
if ! sudo apt-get install -y clang-format-${{ matrix.version }} clang-tidy-${{ matrix.version }}; then
# This LLVM script will add the relevant LLVM PPA: https://apt.llvm.org/
wget https://apt.llvm.org/llvm.sh -O ${{ runner.temp }}/llvm_install.sh
chmod +x ${{ runner.temp }}/llvm_install.sh
if sudo ${{ runner.temp }}/llvm_install.sh ${{ matrix.version }}; then
sudo apt-get install -y clang-format-${{ matrix.version }} clang-tidy-${{ matrix.version }}
fi
fi
- name: Install clang-tools
run: |
python -m pip install clang-tools
clang-tools --install ${{ matrix.version }}
- name: Cache .cargo locked resources
uses: actions/cache/restore@v4
with:
path: ~/.cargo
key: ${{ runner.os }}-test-cargo-${{ hashFiles('Cargo.lock') }}
- name: restore build from artifact
uses: actions/download-artifact@v4
with:
name: cpp-linter-lib_tests-${{ runner.os }}-${{ github.run_id }}
- name: Un-Tar build assets
run: tar -xvf llvm-cov-assets.tar
- name: Collect Coverage
working-directory: cpp-linter-lib
env:
CLANG_VERSION: ${{ matrix.version }}
run: just test
- name: Generate Coverage HTML report
working-directory: cpp-linter-lib
env:
CLANG_VERSION: ${{ matrix.version }}
run: just pretty-cov
- name: Upload coverage data
uses: actions/upload-artifact@v4
with:
name: HTML_report-${{ runner.os }}-clang_v${{ matrix.version }}
path: target/llvm-cov-pretty
- name: Generate Coverage lcov report
if: matrix.version == '16' && runner.os == 'Linux'
working-directory: cpp-linter-lib
env:
CLANG_VERSION: ${{ matrix.version }}
run: |
cargo llvm-cov report --lcov --output-path lcov.info
- uses: codecov/codecov-action@v4
if: matrix.version == '16' && runner.os == 'Linux'
with:
token: ${{secrets.CODECOV_TOKEN}}
files: cpp-linter-lib/lcov.info
fail_ci_if_error: true # optional (default = false)