Skip to content

Update pixi lockfile #332

Update pixi lockfile

Update pixi lockfile #332

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: refred
jobs:
tests:
runs-on: ubuntu-24.04
defaults:
run:
shell: bash -el {0}
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Setup Pixi
uses: prefix-dev/setup-pixi@a09b6247153796b190642a2b53fac4241043cf6f # v0.10.0
- name: mypy type annotations
run: pixi run mypy src/${{ env.PKG_NAME }} test
- name: Unit test with code coverage
run: pixi run test -vv --cov=${{ env.PKG_NAME }} --cov-report=xml --cov-report=term
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v7
with:
verbose: true
token: ${{ secrets.CODECOV_TOKEN }} # required
build:
runs-on: ubuntu-24.04
permissions:
contents: read # for actions/checkout
security-events: write # for github/codeql-action/upload-sarif to upload results
actions: read # for upload-sarif to read run status (private repos)
defaults:
run:
shell: bash -el {0}
steps:
- name: Checkout
uses: actions/checkout@v7
with:
fetch-depth: 100
fetch-tags: true
ref: ${{ github.ref }}
- name: Setup Pixi
uses: prefix-dev/setup-pixi@a09b6247153796b190642a2b53fac4241043cf6f # v0.10.0
- name: Build Conda package
run: |
pixi run conda-build
# Copy conda package to workspace root so it can be uploaded as an artifact.
find local-channel -name "*.conda" -exec cp {} . \;
# pkg-verify requires a conda env that already has the package
# installed (and micromamba on PATH); pkg-install sets both up.
- name: Install built conda package
id: install
uses: neutrons/gh-actions/pkg-install@eb7a7c6fcfd0cda1a7b238329afc0afd09a4f4af # v2
with:
package-name: ${{ env.PKG_NAME }}
local-channel: ./local-channel
extra-channels: neutrons mantid
- name: Verify Conda Package
uses: neutrons/gh-actions/pkg-verify@eb7a7c6fcfd0cda1a7b238329afc0afd09a4f4af # v2
with:
package-name: ${{ env.PKG_NAME }}
conda-env-name: ${{ steps.install.outputs.conda-env }}
extra-commands: python -c "import lr_reduction; import mantid; import qtpy; import configobj"
# Audit the dependencies of the conda package we just installed. SARIF
# results are uploaded to GitHub code scanning by the grype action.
- name: Scan installed environment with Grype
uses: neutrons/gh-actions/grype@eb7a7c6fcfd0cda1a7b238329afc0afd09a4f4af # v2
with:
path: ${{ steps.install.outputs.conda-install-dir }}
- name: Upload conda package as artifact
uses: actions/upload-artifact@v7
with:
name: artifact-conda-package
path: ${{ env.PKG_NAME }}-*.conda
publish:
runs-on: ubuntu-24.04
needs: [tests, build]
if: startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/next'
steps:
- name: Checkout
uses: actions/checkout@v7
with:
ref: ${{ github.ref }}
- name: Setup Pixi
uses: prefix-dev/setup-pixi@a09b6247153796b190642a2b53fac4241043cf6f # v0.10.0
- name: Download conda package artifact
uses: actions/download-artifact@v8
with:
name: artifact-conda-package
- name: Upload package to anaconda
uses: neutrons/gh-actions/publish@eb7a7c6fcfd0cda1a7b238329afc0afd09a4f4af # v2
with:
anaconda-token: ${{ secrets.ANACONDA_TOKEN }}
organization: neutrons
package-path: ${{ env.PKG_NAME }}-*.conda
- name: Remove old packages
if: github.ref == 'refs/heads/next'
uses: neutrons/gh-actions/pkg-remove@eb7a7c6fcfd0cda1a7b238329afc0afd09a4f4af # v2
with:
anaconda-token: ${{ secrets.ANACONDA_TOKEN }}
organization: neutrons
package-name: ${{ env.PKG_NAME }}
label: ${{ env.CONDA_LABEL }}
keep: 5
# Trigger GitLab dev deploy pipeline
deploy-dev:
runs-on: ubuntu-latest
needs: build
if: github.ref == 'refs/heads/next'
steps:
- name: Get Environment Name
uses: neutrons/branch-mapper@main
id: env_name
with:
prefix: refred
- name: Trigger Dev Deploy
uses: eic/trigger-gitlab-ci@v3.3
id: trigger
with:
url: https://code.ornl.gov
project_id: 19060
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 for this commit: ${{ steps.trigger.outputs.web_url }}