Skip to content

feat: Notify of I-ALiRT failures #1261

feat: Notify of I-ALiRT failures

feat: Notify of I-ALiRT failures #1261

Workflow file for this run

name: Dev build CI
on:
push:
paths-ignore:
- "README**"
tags:
- "v*"
branches:
- "main"
- "rel/*"
pull_request:
branches:
- "*"
paths-ignore:
- "README**"
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# write to checks/pull-request extra permission needed by 5monkeys/cobertura-action to post coverage stats
# write packages needed by docker image step
permissions:
id-token: write
contents: write
checks: write
packages: write
pull-requests: write
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref_name }}
cancel-in-progress: true
env:
PREFERED_PYTHON_VERSION: "3.12"
CALIBRATION_TAG: "v0.2.0"
MLM_LICENSE_TOKEN: ${{secrets.MLM_LICENSE_TOKEN }}
CALIBRATION_CODE_LOCATION: "src/matlab/calibration"
PYTEST_XDIST_AUTO_NUM_WORKERS : "2"
jobs:
qa:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: pre-commit/[email protected]
build:
strategy:
matrix:
python-versions: ["3.10", "3.11", "3.12", "3.13"]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
# map step outputs to job outputs so they can be share among jobs
outputs:
package_version: ${{ env.PACKAGE_VERSION }}
package_name: ${{ env.PACKAGE_NAME }}
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v5
- uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-versions }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry
- name: Declare version variables for dev builds
id: variables_step_dev
run: |
# Override the version with a dev suffix because we are not on a tag. Tag builds pull version directly from pyproject.toml
poetry version $(poetry version --short)-dev.$GITHUB_RUN_NUMBER
echo "Using version from pyproject.toml file with dev suffix (because not on a tag): $(poetry version --short)"
echo "PACKAGE_NAME=$(poetry version | awk '{print $1}')" >> $GITHUB_ENV
echo "PACKAGE_VERSION=$(poetry version --short)" >> $GITHUB_ENV
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
shell: bash
- name: Declare variables PACKAGE_NAME and PACKAGE_VERSION
id: variables_step
run: |
echo "Version used by poetry: $(poetry version --short)"
echo "PACKAGE_NAME=$(poetry version | awk '{print $1}')" >> $GITHUB_ENV
echo "PACKAGE_VERSION=$(poetry version --short)" >> $GITHUB_ENV
shell: bash
- name: Ensure tag and version match (tag builds only)
run: |
if [[ "${{ github.ref_name }}" != "v${{ env.PACKAGE_VERSION }}" ]]; then
echo "Tag and version do not match. Tag: ${{ github.ref_name }}, Version: ${{ env.PACKAGE_VERSION }}"
exit 1
fi
if: ${{ startsWith(github.ref, 'refs/tags/') }}
shell: bash
- name: build --skip-tests
run: ./build.sh --skip-tests
- name: Build wheels and source tarball
run: ./pack.sh
- name: Create Version file
run: echo "Version ${{ env.PACKAGE_VERSION }}, SHA ${{ github.sha }}, Ref ${{ github.ref_name }}" > dist/python${{matrix.python-versions}}/version.txt
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
if: matrix.python-versions == env.PREFERED_PYTHON_VERSION
- name: Login to GitHub Container registry ghcr.io
uses: docker/login-action@v3
if: matrix.python-versions == env.PREFERED_PYTHON_VERSION
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Get image metadata
id: meta
uses: docker/metadata-action@v5
if: matrix.python-versions == env.PREFERED_PYTHON_VERSION
with:
images: ghcr.io/${{ github.repository }}
tags: |
# minimal
type=semver,pattern={{version}}
# use custom value instead of git tag
type=semver,pattern={{version}},value=${{ env.PACKAGE_VERSION }}
# set latest tag for default branch
type=raw,value=latest,enable={{is_default_branch}}
# branch event
type=ref,event=branch
# pull request event
type=ref,event=pr
- name: Build and push Docker image
uses: docker/build-push-action@v6
if: matrix.python-versions == env.PREFERED_PYTHON_VERSION
with:
context: .
file: deploy/Dockerfile
push: true
tags: |
${{ steps.meta.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Zip up the folder
run: zip -r ${{ env.PACKAGE_NAME }}_python${{matrix.python-versions}}_${{ env.PACKAGE_VERSION }}.zip python${{matrix.python-versions}}
working-directory: dist
- name: Upload python wheel/tarball
uses: actions/upload-artifact@v4
with:
name: ${{ env.PACKAGE_NAME }}_python${{matrix.python-versions}}_${{ env.PACKAGE_VERSION }}.zip
path: dist/${{ env.PACKAGE_NAME }}_python${{matrix.python-versions}}_${{ env.PACKAGE_VERSION }}.zip
if-no-files-found: error
- name: Create Release ${{github.ref_name}} & upload artifacts
uses: softprops/action-gh-release@v2
if: ${{ startsWith(github.ref, 'refs/tags/') }}
with:
draft: false
prerelease: false
fail_on_unmatched_files: true
files: |
dist/${{ env.PACKAGE_NAME }}_python${{matrix.python-versions}}_${{ env.PACKAGE_VERSION }}.zip
tests:
strategy:
matrix:
python-versions: ["3.10", "3.11", "3.12", "3.13"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-versions }}
- name: Check out calibration code into ${{ env.CALIBRATION_CODE_LOCATION }} in repository
uses: actions/checkout@v5
if: github.event.pull_request.user.login != 'dependabot[bot]'
with:
path: ${{ env.CALIBRATION_CODE_LOCATION}}
sparse-checkout: |
+calibration
+general
external-packages
repository: ${{ vars.CALIBRATION_REPO }}
ssh-key: ${{ secrets.IMAP_MAG_CALIBRATION_DEPLOY_KEY }}
ref: ${{ env.CALIBRATION_TAG }}
- name: Set up MATLAB
uses: matlab-actions/setup-matlab@v2
- name: Run Tests
run: |
python -m pip install poetry
./build.sh
- name: Upload Coverage report
uses: actions/upload-artifact@v4
if: matrix.python-versions == env.PREFERED_PYTHON_VERSION
with:
name: CoverageReport_python${{matrix.python-versions}}
path: htmlcov
if-no-files-found: error
- name: Test Report
uses: dorny/test-reporter@v2
if: ${{ !cancelled() }} && ${{ hashFiles('test-results.xml') != '' }}
with:
name: Test Results (${{ matrix.python-versions }})
path: "test-results.xml"
reporter: java-junit
- name: Coverage Report
uses: 5monkeys/cobertura-action@v14
if: matrix.python-versions == env.PREFERED_PYTHON_VERSION
with:
report_name: Coverage Report (${{ matrix.python-versions }})
path: "coverage.xml"
minimum_coverage: 80
matlab-build:
strategy:
matrix:
python-versions: ["3.10", "3.11", "3.12", "3.13"]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
# map step outputs to job outputs so they can be share among jobs
outputs:
package_version: ${{ env.PACKAGE_VERSION }}
package_name: ${{ env.PACKAGE_NAME }}
steps:
# builds fail with not enough space - needs more than the default 16GB!! in GH Actions default runners
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
# this might remove tools that are actually needed,
# if set to "true" but frees about 6 GB
tool-cache: true
# Each of these frees more space, takes more time
android: false
dotnet: false
haskell: false
large-packages: false
docker-images: false
swap-storage: false
- uses: actions/checkout@v5
- uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-versions }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry
- name: Declare version variables for dev builds
id: variables_step_dev
run: |
# Override the version with a dev suffix because we are not on a tag. Tag builds pull version directly from pyproject.toml
poetry version $(poetry version --short)-dev.$GITHUB_RUN_NUMBER
echo "Using version from pyproject.toml file with dev suffix (because not on a tag): $(poetry version --short)"
echo "PACKAGE_NAME=$(poetry version | awk '{print $1}')" >> $GITHUB_ENV
echo "PACKAGE_VERSION=$(poetry version --short)" >> $GITHUB_ENV
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
shell: bash
- name: Declare variables PACKAGE_NAME and PACKAGE_VERSION
id: variables_step
run: |
echo "Version used by poetry: $(poetry version --short)"
echo "PACKAGE_NAME=$(poetry version | awk '{print $1}')" >> $GITHUB_ENV
echo "PACKAGE_VERSION=$(poetry version --short)" >> $GITHUB_ENV
shell: bash
- name: Ensure tag and version match (tag builds only)
run: |
if [[ "${{ github.ref_name }}" != "v${{ env.PACKAGE_VERSION }}" ]]; then
echo "Tag and version do not match. Tag: ${{ github.ref_name }}, Version: ${{ env.PACKAGE_VERSION }}"
exit 1
fi
if: ${{ startsWith(github.ref, 'refs/tags/') }}
shell: bash
- name: Check out calibration code into ${{ env.CALIBRATION_CODE_LOCATION }} in repository
uses: actions/checkout@v5
if: github.event.pull_request.user.login != 'dependabot[bot]'
with:
path: ${{ env.CALIBRATION_CODE_LOCATION}}
sparse-checkout: |
+calibration
+general
external-packages
repository: ${{ vars.CALIBRATION_REPO }}
ssh-key: ${{ secrets.IMAP_MAG_CALIBRATION_DEPLOY_KEY }}
ref: ${{ env.CALIBRATION_TAG }}
- name: build --skip-tests
run: ./build.sh --skip-tests
- name: Build wheels and source tarball
run: ./pack.sh
- name: Create Version file
run: echo "Version ${{ env.PACKAGE_VERSION }}, SHA ${{ github.sha }}, Ref ${{ github.ref_name }}" > dist/python${{matrix.python-versions}}/version.txt
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
if: matrix.python-versions == env.PREFERED_PYTHON_VERSION
- name: Login to GitHub Container registry ghcr.io
uses: docker/login-action@v3
if: matrix.python-versions == env.PREFERED_PYTHON_VERSION
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Get image metadata
id: meta
uses: docker/metadata-action@v5
if: matrix.python-versions == env.PREFERED_PYTHON_VERSION
with:
images: ghcr.io/${{ github.repository }}/${{ vars.CALIBRATION_IMAGE_NAME }}
tags: |
# minimal
type=semver,pattern={{version}}
# use custom value instead of git tag,prefix=matlab-
type=semver,pattern={{version}},value=${{ env.PACKAGE_VERSION }},prefix=matlab-
# set latest tag for default branch
type=raw,value=latest,prefix=matlab-,enable={{is_default_branch}}
# branch event
type=ref,event=branch,prefix=matlab-
# pull request event
type=ref,event=pr,prefix=matlab-pr-
- name: Build and push Docker image
uses: docker/build-push-action@v6
if: matrix.python-versions == env.PREFERED_PYTHON_VERSION
with:
context: .
file: deploy/MATLAB-Dockerfile
push: true
tags: |
${{ steps.meta.outputs.tags }}
cache-from: type=gha,scope=matlab_imap_pipeline_core_embedded
cache-to: type=gha,mode=max,scope=matlab_imap_pipeline_core_embedded