Skip to content

Commit

Permalink
feat: Split the tests per compiler and operating system on the upstre…
Browse files Browse the repository at this point in the history
…am workflows
  • Loading branch information
TheRustifyer committed May 25, 2024
1 parent 65684f5 commit b7131db
Show file tree
Hide file tree
Showing 10 changed files with 459 additions and 44 deletions.
54 changes: 10 additions & 44 deletions .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Code quality and sanity

on:
push:
branches: '*'
branches: 'main'
pull_request:
branches: '*'

Expand All @@ -22,12 +22,12 @@ jobs:
- uses: hecrj/setup-rust-action@v1
with:
components: clippy
- name: Verifiying the code quality with Clippy

- name: Verifiying the code quality with Clippy
run: |
cd zork++
cargo clippy --all-targets --all-features
rustfmt:
name: Verify code formatting
runs-on: ubuntu-latest
Expand All @@ -36,51 +36,17 @@ jobs:
- name: Caching project dependencies
id: project-cache
uses: Swatinem/rust-cache@v2
- uses: hecrj/setup-rust-action@v1

- uses: hecrj/setup-rust-action@v2
with:
components: rustfmt

- name: Checking the format sanity of the project
run: |
cd zork++
cargo fmt --all -- --check
tests:
name: Run the tests - Clang
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
clang_version: [15, 16, 17]
steps:
- uses: actions/checkout@v3
- name: Caching project dependencies
id: project-cache
uses: Swatinem/rust-cache@v2
- name: Install Clang ${{ matrix.clang_version }}
run: |
# Exit on error
set -e
# Download and execute the LLVM installation script for the specified Clang version
echo "-----> Downloading and executing the LLVM installation script for Clang ${{ matrix.clang_version }}"
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh ${{ matrix.clang_version }}
echo "-----> Installing libc++"
sudo apt-get install -y libc++-${{ matrix.clang_version }}-dev libc++abi-${{ matrix.clang_version }}-dev libunwind-${{ matrix.clang_version }} libunwind-${{ matrix.clang_version }}-dev libc6 libzstd1
# Update the symbolic link to point to the newly installed Clang version
echo "-----> Updating the symbolic link to point to Clang ${{ matrix.clang_version }}"
sudo rm -f /usr/bin/clang++
sudo ln -s /usr/bin/clang++-${{ matrix.clang_version }} /usr/bin/clang++

# Display the installation directory and version of the installed Clang
echo "-----> Clang-${{ matrix.clang_version }} was installed on:"
which clang-${{ matrix.clang_version }}
echo "-----> Clang++ was installed on:"
which clang++-${{ matrix.clang_version }}
- name: Running the tests for the project
- name: Run Unit and Doc tests
run: |
cd zork++
RUST_LOG=trace cargo test 2>&1 --all --color=always --no-fail-fast -- --nocapture --show-output --test-threads=1
cargo test --workspace --lib --color=always --no-fail-fast
cargo test --workspace --doc --color=always --no-fail-fast
52 changes: 52 additions & 0 deletions .github/workflows/tests-clang-linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Clang Tests For Linux builds

on:
push:
branches: 'main'
pull_request:
branches: '*'

jobs:
tests:
name: Run the tests - Clang
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
clang_version: [15, 16, 17, 18]
steps:
- uses: actions/checkout@v3
- name: Caching project dependencies
id: project-cache
uses: Swatinem/rust-cache@v2

- if: ${{ matrix.clang_version < 18 }}
name: Install Clang ${{ matrix.clang_version }}
run: |
# Exit on error
set -e
# Download and execute the LLVM installation script for the specified Clang version
echo "-----> Downloading and executing the LLVM installation script for Clang ${{ matrix.clang_version }}"
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh ${{ matrix.clang_version }}
echo "-----> Installing libc++"
sudo apt-get install -y libc++-${{ matrix.clang_version }}-dev libc++abi-${{ matrix.clang_version }}-dev libunwind-${{ matrix.clang_version }} libunwind-${{ matrix.clang_version }}-dev libc6 libzstd1
# Update the symbolic link to point to the newly installed Clang version
echo "-----> Updating the symbolic link to point to Clang ${{ matrix.clang_version }}"
sudo rm -f /usr/bin/clang++
sudo ln -s /usr/bin/clang++-${{ matrix.clang_version }} /usr/bin/clang++
# Display the installation directory and version of the installed Clang
echo "-----> Clang-${{ matrix.clang_version }} was installed on:"
which clang-${{ matrix.clang_version }}
echo "-----> Clang++ was installed on:"
which clang++-${{ matrix.clang_version }}
- if: ${{ matrix.clang_version < 18 }}
name: Running the tests for the project
run: |
cd zork++
RUST_LOG=trace cargo test 2>&1 clang --color=always --no-fail-fast -- --nocapture --show-output --test-threads=1
25 changes: 25 additions & 0 deletions .github/workflows/tests-gcc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: GCC Tests For Linux builds

on:
push:
branches: 'main'
pull_request:
branches: '*'

jobs:
tests:
name: Run the tests - GCC
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v3

- name: Caching project dependencies
id: project-cache
uses: Swatinem/rust-cache@v2

- name: Running the tests for the project
run: |
cd zork++
RUST_LOG=trace cargo test 2>&1 gcc --color=always --no-fail-fast -- --nocapture --show-output --test-threads=1
30 changes: 30 additions & 0 deletions .github/workflows/tests-msvc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: MSVC Tests For Windows builds

on:
push:
branches: 'main'
pull_request:
branches: '*'

jobs:
tests:
name: Run the tests - MSVC
runs-on: windows-latest
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v3

- name: Caching project dependencies
id: project-cache
uses: Swatinem/rust-cache@v2

- name: Setting up Rust
uses: hecrj/setup-rust-action@v1
with:
rust-version: stable

- name: Running the tests for the project
run: |
cd zork++
cargo test 2>&1 msvc --color=always --no-fail-fast -- --nocapture --show-output --test-threads=1
64 changes: 64 additions & 0 deletions workflows/code-coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Code Coverage

on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+rc[0-9]+'

env:
CARGO_TERM_COLOR: always

jobs:
code-coverage:
permissions:
contents: write
env:
CARGO_INCREMENTAL: '0'
RUSTFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests'
RUSTDOCFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Use nightly toolchain
run: |
rustup toolchain install nightly
rustup override set nightly
- name: Caching cargo dependencies
id: project-cache
uses: Swatinem/rust-cache@v2

- if: ${{ steps.cache-cargo.outputs.cache-hit != 'true' }}
name: Install grcov
run: cargo install grcov

- name: Make the USER own the working directory
if: ${{ matrix.os == 'ubuntu-latest' }}
run: sudo chown -R $USER:$USER ${{ github.workspace }}

- name: Run tests
working-directory: zork++
run: |
cargo test --all-features --no-fail-fast --target=x86_64-unknown-linux-gnu -- --show-output --test-threads=1
- name: Generate code coverage report
working-directory: zork++
run: |
grcov . -s . --binary-path ./target/debug/ -t html --branch --ignore-not-existing -o ./target/debug/coverage
grcov . -s . --binary-path ./target/debug/ -t cobertura --branch --ignore-not-existing -o ./target/debug/coverage/code_cov.xml
- name: Publish Test Results
uses: actions/upload-artifact@v3
with:
name: Unit Test Results
path: |
./zork++/target/debug/coverage/code_cov.xml
./zork++/target/debug/coverage/index.html
- name: Publish coverage report to GitHub Pages
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: ./zork++/target/debug/coverage
token: ${{ secrets.GITHUB_TOKEN }}
52 changes: 52 additions & 0 deletions workflows/code-quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Code quality and sanity

on:
push:
branches: 'main'
pull_request:
branches: '*'

jobs:
clippy:
name: Lint with Clippy
runs-on: ubuntu-latest
env:
RUSTFLAGS: -Dwarnings
steps:
- uses: actions/checkout@v3

- name: Caching project dependencies
id: project-cache
uses: Swatinem/rust-cache@v2

- uses: hecrj/setup-rust-action@v1
with:
components: clippy

- name: Verifiying the code quality with Clippy
run: |
cd zork++
cargo clippy --all-targets --all-features
rustfmt:
name: Verify code formatting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Caching project dependencies
id: project-cache
uses: Swatinem/rust-cache@v2

- uses: hecrj/setup-rust-action@v2
with:
components: rustfmt

- name: Checking the format sanity of the project
run: |
cd zork++
cargo fmt --all -- --check
- name: Run Unit and Doc tests
run: |
cargo test --workspace --lib --color=always --no-fail-fast
cargo test --workspace --doc --color=always --no-fail-fast
Loading

0 comments on commit b7131db

Please sign in to comment.