Skip to content

PyRS CI

PyRS CI #691

Workflow file for this run

name: PyRS CI
on:
workflow_dispatch:
pull_request:
push:
branches:
- next
tags:
- v*
schedule: # daily cron job at UTC+6 == EST+1 on default branch
- cron: '0 6 * * *'
env:
TRIGGER_URL: "https://code.ornl.gov/api/v4/projects/6012/trigger/pipeline"
jobs:
ci:
runs-on: ubuntu-latest
timeout-minutes: 600
defaults:
run:
shell: bash -l {0}
steps:
- uses: actions/checkout@v2
- name: Apt install deps
run: |
sudo apt update
sudo apt-get install xvfb freeglut3-dev libglu1-mesa
- uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
- name: Setup libmamba solver
run: |
conda install -n base conda-libmamba-solver
conda config --set solver libmamba
conda install boa -c conda-forge
- name: Install requirements
run: |
# --quiet should turn off progress bars to make logs more readable
conda env create --file environment.yml --quiet
- name: Lint
run: |
conda activate PyRS
flake8 . --count
- name: mypy
run: |
conda activate PyRS
mypy pyrs scripts tests
- name: Mantid pre-requisites - create a properties file that turns off network access
run: |
conda activate PyRS
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 mantid/workbench
run: |
conda activate PyRS
python -c "import mantid"
python -c "import qtpy"
python -c "import mantidqt"
- name: Print Conda Packages
run: |
conda activate PyRS
conda list
- name: Run PyRS tests
run: |
conda activate PyRS
xvfb-run --server-args="-screen 0 640x480x24" -a pytest --cov=pyrs --cov-report=xml --cov-report=term tests
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
- name: Build python wheel # cannot be used without mantid
run: |
conda activate PyRS
python setup.py bdist_wheel
check-wheel-contents dist/pyrs-*.whl
- name: Build conda package
# Build in all cases, for testing purposes
run: |
conda activate PyRS
cd conda.recipe
conda-mambabuild --output-folder . . -c conda-forge -c mantid
conda-verify noarch/pyrs-*py*.tar.bz2
- name: Publish to Anaconda
shell: bash -l {0}
# Publish only for version tags (tag name starts with "v")
if: startsWith(github.ref, 'refs/tags/v')
env:
ANACONDA_API_TOKEN: ${{ secrets.ANACONDA_TOKEN }}
# IS_RC: "true" for release-candidate tags, e.g. "v1.0.0-rc1"
IS_RC: ${{ contains(github.ref, 'rc') }}
run: |
conda activate PyRS
conda install -y anaconda-client
CONDA_LABEL="main"
if [ "${IS_RC}" = "true" ]; then CONDA_LABEL="rc"; fi
echo "pushing ${{ github.ref }} with label ${CONDA_LABEL}"
anaconda upload --label ${CONDA_LABEL} conda.recipe/noarch/pyrs-*.tar.bz2
trigger-deploy:
runs-on: ubuntu-22.04
needs: [ci]
# Deploys from branch next (except when running the nightly cron), or from a version tag
if: |
startsWith(github.ref, 'refs/tags/v') ||
(github.ref == 'refs/heads/next' && github.event_name != 'schedule')
steps:
- name: Determine Environment
uses: neutrons/branch-mapper@v2
id: conda_env_name
with:
prefix: pyrs
- name: Trigger deploy
id: trigger
uses: eic/trigger-gitlab-ci@v2
with:
url: https://code.ornl.gov
token: ${{ secrets.GITLAB_TRIGGER_TOKEN }}
project_id: 11849
variables: |
PLAY="update"
CONDA_ENV="${{ steps.conda_env_name.outputs.name }}"
- name: Annotate commit
uses: peter-evans/commit-comment@v2
with:
body: |
GitLab pipeline for ${{ steps.conda_env_name.outputs.name }} has been submitted for this commit: ${{ steps.trigger.outputs.web_url }}