diff --git a/.github/problem-matchers.json b/.github/problem-matchers.json new file mode 100644 index 00000000..8b10ca54 --- /dev/null +++ b/.github/problem-matchers.json @@ -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 + } + ] + } + ] +} \ No newline at end of file diff --git a/.github/workflows/Ubuntu.yml b/.github/workflows/Ubuntu.yml new file mode 100644 index 00000000..bcd88119 --- /dev/null +++ b/.github/workflows/Ubuntu.yml @@ -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