Skip to content

Check peak-range files in one place and set d0 in autoreduction (#1147) #455

Check peak-range files in one place and set d0 in autoreduction (#1147)

Check peak-range files in one place and set d0 in autoreduction (#1147) #455

name: Tests, Package, and Deployment
on:
workflow_dispatch:
pull_request:
push:
branches: [next, qa, main]
tags: ["v*"]
# cancel previous job if new commit is pushed
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
PKG_NAME: pyrs
MODULE_NAME: pyrs
CONDA_ORG: neutrons
jobs:
# The four test tiers (CLAUDE.md) run as parallel jobs, unit and integration each with
# pytest-xdist (#1100); ring-calibration is serial, so its shared calibration is computed once
# (#1101). `tests` below gathers them, so the check name and `publish`'s needs are unchanged.
test-tier:
name: tests (${{ matrix.tier }})
runs-on: ubuntu-latest
# id-token lets the Codecov upload authenticate by OIDC instead of a CODECOV_TOKEN secret,
# which Codecov requires for every non-fork branch (it rejected all next uploads without one)
permissions:
contents: read
id-token: write
strategy:
fail-fast: false
matrix:
tier: [unit, ring-calibration, integration, gui]
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
fetch-tags: true
- uses: prefix-dev/setup-pixi@9936258fee697aff89b3fed6ca1f80a382ef694e # v0.11.3
with:
pixi-version: v0.81.0
manifest-path: pyproject.toml
# every tier needs a display: collecting ./tests imports the GUI modules, whatever the
# tier runs
- name: Apt install deps
run: |
sudo apt update
sudo apt-get install xvfb freeglut3-dev libglu1-mesa
- name: Start xvfb daemon
run: |
/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile \
--background --exec /usr/bin/Xvfb -- :99 -ac -screen 0 1280x1024x16
- name: Mantid pre-requisites - create a properties file that turns off network access
run: |
mkdir ~/.mantid
echo "CheckMantidVersion.OnStartup=0" > ~/.mantid/Mantid.user.properties
echo "UpdateInstrumentDefinitions.OnStartup=0" >> ~/.mantid/Mantid.user.properties
echo "usagereports.enabled=0" >> ~/.mantid/Mantid.user.properties
- name: Test framework imports
run: pixi run test-import-framework
- name: run ${{ matrix.tier }} tests
run: |
echo "running ${{ matrix.tier }} tests"
xvfb-run --server-args="-screen 0 1280x1024x16" -a pixi run test-ci-${{ matrix.tier }}
- name: List coverage files (debug)
run: |
echo "Coverage files generated:"
ls -la coverage.xml || echo "No coverage.xml found"
- name: upload coverage to codecov
uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7.1.1
if: github.actor != 'dependabot[bot]'
with:
use_oidc: true
files: ./coverage.xml
flags: ${{ matrix.tier }}
name: codecov-${{ matrix.tier }}
# A rejected upload on next/main must be visible (it went unnoticed for two years);
# on PRs a Codecov outage should not block merging.
fail_ci_if_error: ${{ github.event_name == 'push' }}
verbose: true
tests:
needs: [test-tier]
if: ${{ !cancelled() }}
runs-on: ubuntu-latest
steps:
- name: every test tier passed
run: |
echo "unit, ring-calibration, integration and gui: ${{ needs.test-tier.result }}"
test "${{ needs.test-tier.result }}" = "success"
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
fetch-tags: true
- uses: prefix-dev/setup-pixi@9936258fee697aff89b3fed6ca1f80a382ef694e # v0.11.3
with:
pixi-version: v0.81.0
manifest-path: pyproject.toml
- name: mypy
run: pixi run mypy pyrs scripts tests
conda-build:
name: Build conda package
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7
with:
fetch-depth: 0
fetch-tags: true
- name: Setup pixi
uses: prefix-dev/setup-pixi@9936258fee697aff89b3fed6ca1f80a382ef694e # v0.11.3
with:
pixi-version: v0.81.0
manifest-path: pyproject.toml
- name: Build conda package
run: |
pixi run conda-build
mkdir -p ${{ runner.temp }}/local-channel/linux-64
cp *.conda ${{ runner.temp }}/local-channel/linux-64
- name: Install package
id: install
uses: neutrons/gh-actions/pkg-install@46e28a74c8872901c571e0493d26871afe2662fb # v2.1
with:
package-name: ${{ env.PKG_NAME }}
local-channel: ${{ runner.temp }}/local-channel/
post-cleanup: none
# mantid first: mantid-ornl has no 7.x yet (docs/ground_truths.md)
extra-channels: mantid neutrons
- name: Verify conda package
uses: neutrons/gh-actions/pkg-verify@46e28a74c8872901c571e0493d26871afe2662fb # v2.1
with:
package-name: ${{ env.PKG_NAME }}
conda-env-name: ${{ steps.install.outputs.conda-env }}
module-name: ${{ env.MODULE_NAME }}
extra-commands: |
python -c "import mantid"
- name: Upload conda package as artifact
uses: actions/upload-artifact@v7
with:
name: artifact-conda-package
path: ${{ env.PKG_NAME }}-*.conda
publish:
name: Upload package to anaconda
runs-on: ubuntu-latest
needs: [conda-build, tests, lint]
if: startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/next'
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Setup Pixi
uses: prefix-dev/setup-pixi@9936258fee697aff89b3fed6ca1f80a382ef694e # v0.11.3
with:
pixi-version: v0.81.0
manifest-path: pyproject.toml
activate-environment: true
- name: Download conda package artifact
id: download
uses: actions/download-artifact@v8
with:
name: artifact-conda-package
- name: List package directory
run: ls -l ${{ steps.download.outputs.download-path }}
- name: Upload package to anaconda
uses: neutrons/gh-actions/publish@46e28a74c8872901c571e0493d26871afe2662fb # v2.1
with:
anaconda-token: ${{ secrets.ANACONDA_TOKEN }}
organization: ${{ env.CONDA_ORG }}
package-path: ${{ steps.download.outputs.download-path }}/${{ env.PKG_NAME }}-*.conda
- name: Remove old packages
if: github.ref == 'refs/heads/next'
uses: neutrons/gh-actions/pkg-remove@46e28a74c8872901c571e0493d26871afe2662fb # v2.1
with:
anaconda-token: ${{ secrets.ANACONDA_TOKEN }}
organization: ${{ env.CONDA_ORG }}
package-name: ${{ env.PKG_NAME }}
label: ${{ env.CONDA_LABEL }}
keep: 5
# Trigger GitLab dev deploy pipeline
deploy-dev:
runs-on: ubuntu-latest
needs: [publish]
if: github.ref == 'refs/heads/next' && github.event_name != 'schedule'
steps:
- name: Get Environment Name
uses: neutrons/gh-actions/branch-mapper@46e28a74c8872901c571e0493d26871afe2662fb # v2.1
id: env_name
with:
prefix: ${{ env.PKG_NAME }}
- name: Trigger Dev Deploy
# use https://github.com/eic/trigger-gitlab-ci/pull/14 until merged
uses: eic/trigger-gitlab-ci@d984d8d53d871d2fdc1325639d94322da6e8747f
id: trigger
with:
url: https://code.ornl.gov
project_id: 18073
ref_name: main
token: ${{ secrets.GITLAB_DEPLOY_TOKEN }}
- name: Annotate commit
uses: peter-evans/commit-comment@v4
with:
body: |
GitLab pipeline for ${{ steps.env_name.outputs.name }}
has been submitted: ${{ steps.trigger.outputs.web_url }}