Skip to content

Merge pull request #9 from neutrons/fix_labels #37

Merge pull request #9 from neutrons/fix_labels

Merge pull request #9 from neutrons/fix_labels #37

name: Tests, Package, and Deployment
on:
workflow_dispatch:
pull_request:
push:
branches: [next, qa, main]
tags: ["v*"]
env:
PKG_NAME: dgs_resolution
MODULE_NAME: dgs_resolution
# cancel previous job if new commit is pushed
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
# tests:
# name: Unit tests
# runs-on: ubuntu-latest
# steps:
# - name: Checkout
# uses: actions/checkout@v6
# with:
# fetch-depth: 0
# fetch-tags: true
# - name: Setup pixi
# uses: prefix-dev/setup-pixi@v0.9.5
# with:
# pixi-version: v0.62.2
# manifest-path: pyproject.toml
# # Workaround: Dynamic versioning (versioningit) causes lock file version mismatch.
# # We skip the editable package install and do it separately with pip.
# # See: https://github.com/prefix-dev/pixi/pull/3092
# run-install: false
# - name: Install dependencies (skip local package)
# run: pixi install --frozen --skip ${{ env.PKG_NAME }}
# - name: Install local package
# run: pixi run pip install --no-deps -e .
# - name: Run unit tests
# run: pixi run xvfb-run --server-args="-screen 0 1920x1080x24" -a python -m pytest --cov=src --cov-report=xml --cov-report=term
# - name: Upload coverage to codecov
# uses: codecov/codecov-action@v5
# if: github.actor != 'dependabot[bot]'
# with:
# token: ${{ secrets.CODECOV_TOKEN }}
conda-build:
name: Build conda package
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
fetch-tags: true
- name: Setup pixi
uses: prefix-dev/setup-pixi@v0.9.5
with:
pixi-version: v0.62.2
manifest-path: pyproject.toml
# Workaround: Dynamic versioning (versioningit) causes lock file version mismatch.
# We skip the editable package install and do it separately with pip.
# See: https://github.com/prefix-dev/pixi/pull/3092
run-install: false
- name: Install dependencies (skip local package)
run: pixi install --frozen --skip ${{ env.PKG_NAME }}
- name: Install local package
run: pixi run pip install --no-deps -e .
- name: Build conda package
run: |
pixi run conda-build
mkdir -p /tmp/local-channel/linux-64
cp *.conda /tmp/local-channel/linux-64
- name: Verify conda package
uses: neutrons/conda-actions/pkg-verify@main
with:
package-name: ${{ env.PKG_NAME }}
module-name: ${{ env.MODULE_NAME }}
local-channel: /tmp/local-channel
extra-channels: neutrons
python-version: "3.11"
- 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
if: startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/next'
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
fetch-tags: true
- name: Setup Pixi
uses: prefix-dev/setup-pixi@v0.9.5
with:
pixi-version: v0.62.2
manifest-path: pyproject.toml
# Workaround: Dynamic versioning (versioningit) causes lock file version mismatch.
# We skip the editable package install and do it separately with pip.
# See: https://github.com/prefix-dev/pixi/pull/3092
run-install: false
- name: Install dependencies (skip local package)
run: pixi install --frozen --skip ${{ env.PKG_NAME }}
- name: Download conda package artifact
uses: actions/download-artifact@v8
with:
name: artifact-conda-package
- name: Upload package to anaconda
uses: neutrons/conda-actions/publish@main
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/conda-actions/pkg-remove@v1
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: conda-build
if: github.ref == 'refs/heads/next'
steps:
- name: Get Environment Name
uses: neutrons/branch-mapper@main
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: 20651
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 }}