Skip to content

Clean-up Model preference code #711

Clean-up Model preference code

Clean-up Model preference code #711

Workflow file for this run

name: Main
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
pull_request:
branches:
- main
push:
branches:
- main
tags:
- 'v*'
env:
# Change this to invalidate existing cache.
# CACHE_PREFIX: v0
# PYTHONPATH: ./
PYTEST_ADDOPTS: -v --color=yes
GITHUB_PR_NUMBER: ${{ github.event.number }}
jobs:
build:
name: Build
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
steps:
- uses: actions/checkout@v4
- name: Setup Python environment
uses: ./.github/actions/setup-venv
with:
python-version: "3.11"
# cache-prefix: ${{ env.CACHE_PREFIX }}
- run: |
source .venv/bin/activate
python -m pip install --upgrade build
python -m build
- uses: actions/upload-artifact@v4
with:
name: asgardpy-release
path: dist/
- name: Clean up
run: |
source .venv/bin/activate
pip uninstall -y asgardpy
docs:
name: Build docs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Python environment
uses: ./.github/actions/setup-venv
with:
python-version: '3.11'
# cache-prefix: ${{ env.CACHE_PREFIX }}
- name: Produce Changelog
run: |
python -m pip install towncrier
python -m pip install -e .[dev]
towncrier build --yes
- name: Docs
run: |
source .venv/bin/activate
cd docs && make html
- name: Clean up
run: |
source .venv/bin/activate
pip uninstall -y asgardpy
tests:
name: ${{ matrix.os }} - ${{ matrix.tox_env }}
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.allowed_fail }}
timeout-minutes: 45
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
python: '3.11'
enableCrossOsArchive: true
path: ~/.cache/pip
venv_activate_command: "source .venv/bin/activate"
tox_env: 'py311-test-quick'
gammapy_data_path: /home/runner/work/asgardpy/asgardpy/gammapy-datasets/1.2/
allowed_fail: false
- os: ubuntu-latest
python: '3.12'
enableCrossOsArchive: true
path: ~/.cache/pip
venv_activate_command: "source .venv/bin/activate"
tox_env: 'py312-test-quick'
gammapy_data_path: /home/runner/work/asgardpy/asgardpy/gammapy-datasets/1.2/
allowed_fail: false
- os: macos-latest
python: '3.11'
enableCrossOsArchive: true
path: ~/Library/Caches/pip
venv_activate_command: "source .venv/bin/activate"
tox_env: 'py311-test-quick'
gammapy_data_path: /Users/runner/work/asgardpy/asgardpy/gammapy-datasets/1.2/
allowed_fail: false
- os: macos-latest
python: '3.12'
enableCrossOsArchive: true
path: ~/Library/Caches/pip
venv_activate_command: "source .venv/bin/activate"
tox_env: 'py312-test-quick'
gammapy_data_path: /Users/runner/work/asgardpy/asgardpy/gammapy-datasets/1.2/
allowed_fail: false
- os: windows-latest
python: '3.11'
shell: pwsh
enableCrossOsArchive: true
path: ~\AppData\Local\pip\Cache
venv_activate_command: .\venv\Scripts\activate
tox_env: 'py311-test-quick'
gammapy_data_path: D:\a\asgardpy\asgardpy\gammapy-datasets\1.2\
allowed_fail: false
- os: windows-latest
python: '3.12'
shell: pwsh
enableCrossOsArchive: true
path: ~\AppData\Local\pip\Cache
venv_activate_command: .\venv\Scripts\activate
tox_env: 'py312-test-quick'
gammapy_data_path: D:\a\asgardpy\asgardpy\gammapy-datasets\1.2\
allowed_fail: false
steps:
- name: Increase swapfile
if: "contains(matrix.os, 'ubuntu')"
run: |
sudo swapoff -a
sudo fallocate -l 15G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo swapon --show
- uses: actions/checkout@v4
- name: Setup Python ${{ matrix.python }} environment
uses: ./.github/actions/setup-venv
with:
python-version: ${{ matrix.python }}
# cache-prefix: ${{ env.CACHE_PREFIX }}
- name: Download Gammapy Datasets
if: ${{ matrix.gammapy_data_path }}
run: |
python -m pip install tqdm requests
python -m pip install -e .[dev]
gammapy download datasets
- name: Download extra test data
if: ${{ matrix.gammapy_data_path}}
env:
GAMMAPY_DATA: ${{ matrix.gammapy_data_path}}
run: |
sh ./scripts/download_asgardpy_data.sh
- name: Test
if: ${{ matrix.gammapy_data_path }}
env:
GAMMAPY_DATA: ${{ matrix.gammapy_data_path}}
run: |
echo ${{ matrix.venv_activate_command }}
tox -e ${{ matrix.tox_env }}
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
file: ./coverage.xml
verbose: true
- name: Clean up
run: |
echo ${{ matrix.venv_activate_command }}
pip uninstall -y asgardpy
release: # Separate this into a unique yml file?
name: Release
runs-on: ubuntu-latest
needs: [tests] # Only build is used in standard PyPA
if: startsWith(github.ref, 'refs/tags/')
# Specifying a GitHub environment is optional, but strongly encouraged
environment: release
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install requirements
run: |
pip install --upgrade build towncrier
python -m build
- name: Prepare environment
run: |
echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV
echo "TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
- name: Download package distribution files
uses: actions/download-artifact@v4
with:
name: asgardpy-release
path: dist/
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
verbose: true
- name: Publish GitHub release
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: |
dist/*