Generate code coverage report and deploy it to Coveralls.io #443
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- '.github/workflows/ci.yml' | |
- '**/*.cpp' | |
- '**/*.hpp' | |
- '**/CMakeLists.txt' | |
pull_request: | |
branches: | |
- main | |
paths: | |
- '.github/workflows/ci.yml' | |
- '**/*.cpp' | |
- '**/*.hpp' | |
- '**/CMakeLists.txt' | |
jobs: | |
code-style-check: | |
name: Code style check | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: DoozyX/clang-format-lint-action@v0.17 | |
with: | |
source: './compiler' | |
extensions: 'hpp,cpp' | |
clangFormatVersion: 17 | |
build-gcc: | |
name: Build on Ubuntu GCC | |
runs-on: ubuntu-latest | |
needs: code-style-check | |
container: | |
image: ghcr.io/vla5924-practice/compiler-project/devcontainer:latest | |
options: --user root | |
credentials: | |
username: ${{ github.actor }} | |
password: ${{ secrets.github_token }} | |
steps: | |
- name: Initialize repository | |
uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- name: Build | |
run: | | |
cmake -S compiler -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DENABLE_IR_GENERATOR=OFF | |
ninja -C build | |
- name: Archive binaries | |
run: tar cf binaries.tar -C build bin | |
- name: Upload binaries | |
uses: actions/upload-artifact@v4 | |
with: | |
name: binaries-ubuntu-latest-gcc | |
path: binaries.tar | |
unit-test: | |
name: Unit test | |
runs-on: ubuntu-latest | |
needs: build-gcc | |
container: | |
image: ghcr.io/vla5924-practice/compiler-project/devcontainer:latest | |
options: --user root | |
credentials: | |
username: ${{ github.actor }} | |
password: ${{ secrets.github_token }} | |
steps: | |
- name: Download binaries | |
uses: actions/download-artifact@v4 | |
with: | |
name: binaries-ubuntu-latest-gcc | |
- name: Extract binaries | |
run: tar xf binaries.tar | |
- name: Run AST interface tests | |
run: ./bin/ast_test | |
- name: Run frontend tests | |
run: ./bin/frontend_test | |
- name: Run AST-based backend tests | |
run: ./bin/backend_ast_test | |
code-coverage: | |
name: Code coverage | |
runs-on: ubuntu-latest | |
needs: build-gcc | |
container: | |
image: ghcr.io/vla5924-practice/compiler-project/devcontainer:latest | |
options: --user root | |
credentials: | |
username: ${{ github.actor }} | |
password: ${{ secrets.github_token }} | |
steps: | |
- name: Install dependencies | |
run: | | |
apt-get update | |
apt-get install -y -q --no-install-recommends lcov | |
- name: Initialize repository | |
uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- name: Build and run tests | |
run: | | |
cmake -S compiler -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug -DENABLE_CODEGEN=OFF -DENABLE_COVERAGE=ON | |
cmake --build build --target run_tests --parallel | |
- name: Generate coverage report | |
run: cmake --build build --target coverage | |
- name: Upload coverage report | |
uses: actions/upload-artifact@v4 | |
with: | |
name: code-coverage-report | |
path: build/coverage | |
- name: Post coverage to Coveralls.io | |
uses: coverallsapp/github-action@v2.2.3 | |
with: | |
github-token: ${{ secrets.github_token }} | |
file: ${{ github.workspace }}/build/coverage.info | |
format: lcov | |
fail-on-error: false |