Skip to content

Commit

Permalink
Draft GHA workflow
Browse files Browse the repository at this point in the history
Should compile ffea and tests under multiple versions of GCC
  • Loading branch information
Robadob committed Dec 17, 2024
1 parent 89ac333 commit 2ec8865
Show file tree
Hide file tree
Showing 2 changed files with 133 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .github/problem-matchers.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"problemMatcher": [
{
"owner": "gcc",
"pattern": [
{
"regexp": "^(.*):(\\d+):(\\d+):\\s+(?:fatal\\s+)?(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
]
}
]
}
116 changes: 116 additions & 0 deletions .github/workflows/Ubuntu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
# Guidance: https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions
# Compile project on Ubuntu
name: Ubuntu

on:
# Branch pushes that do not only modify other workflow files
push:
branches:
- '**'
paths:
- "**"
- "!.github/**"
- ".github/workflows/Ubuntu.yml"
# Pull requests to main, that do not only modify other workflow files
pull_request:
branches:
- 'main'
paths:
- "**"
- "!.github/**"
- ".github/workflows/Ubuntu.yml"
# Allow manual invocation.
workflow_dispatch:

defaults:
run:
shell: bash

jobs:
build:
runs-on: ${{ matrix.cxx.os }}
strategy:
fail-fast: false
# Multiplicative build matrix
# optional exclude: can be partial, include: must be specific
matrix:
cxx:
- compiler: gcc-12
os: ubuntu-22.04
- compiler: gcc-11
os: ubuntu-22.04
- compiler: gcc-8
os: ubuntu-20.04
config:
- name: "Release"
config: "Release"
- name: "Debug"
config: "Debug"
# exclude:
exclude:
# Exclude Debug for old GCC
- cxx:
compiler: gcc-11
config:
name: "Debug"
- cxx:
compiler: gcc-8
config:
name: "Debug"

# Name the job based on matrix/env options
name: "build (${{ matrix.cxx.compiler }}, ${{ matrix.config.name }}, ${{ matrix.cxx.os }})"

# Define job-wide env constants, and promote matrix elements to env constants for portable steps.
env:
# Workflow specific constants for building a specific example
# Compute the output name which should be unique within the matrix. This must be unique per build matrix/job combination
ARTIFACT_NAME_FFEA: ffea-${{ matrix.cxx.os }}-${{ matrix.cxx.compiler }}-${{ matrix.config.name }}
ARTIFACT_NAME_FFEAMB: ffea_mb-${{ matrix.cxx.os }}-${{ matrix.cxx.compiler }}-${{ matrix.config.name }}
# Define constants
BUILD_DIR: "build"
COMPILER: ${{ matrix.cxx.compiler }}
OS: ${{ matrix.cxx.os }}
CONFIG: ${{ matrix.config.config }}

# What the CI actually runs
steps:
- uses: actions/checkout@v4

- name: Install/Select gcc and g++
if: ${{ startsWith(env.COMPILER, 'gcc-') }}
run: |
gcc_version=${COMPILER//gcc-/}
sudo apt-get install -y gcc-${gcc_version} g++-${gcc_version}
echo "CC=/usr/bin/gcc-${gcc_version}" >> $GITHUB_ENV
echo "CXX=/usr/bin/g++-${gcc_version}" >> $GITHUB_ENV
# Problem matchers allow compilation warnings/errors to be highlighted on GitHub
- name: Add custom problem matchers for annotations
run: echo "::add-matcher::.github/problem-matchers.json"

- name: Configure cmake
run: >
cmake . -B "${{ env.BUILD_DIR }}"
-DCMAKE_BUILD_TYPE="${{ env.CONFIG }}"
- name: Build ffea
working-directory: ${{ env.BUILD_DIR }}
run: cmake --build . --verbose --parallel `nproc`

# Upload artifacts to the job on GHA, with a short retention
# Use a unique name per job matrix run, to avoid a risk of corruption according to the docs (although it should work with unique filenames)
- name: Upload FFEA Artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.ARTIFACT_NAME_FFEA }}
path: ${{ env.BUILD_DIR }}/src/ffea
if-no-files-found: error
retention-days: 5
- name: Upload FFEA Artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.ARTIFACT_NAME_FFEAMB }}
path: ${{ env.BUILD_DIR }}/src/ffea_mb
if-no-files-found: error
retention-days: 5

0 comments on commit 2ec8865

Please sign in to comment.