Skip to content

Feat/publish action #58

Feat/publish action

Feat/publish action #58

Workflow file for this run

name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
release:
types: [published]
jobs:
tests:
runs-on: ubuntu-latest
defaults:
run:
shell: bash -el {0}
# For the slurm action to work, you have to supply a mysql service as defined below.
services:
mysql:
image: mysql:8.0
env:
MYSQL_ROOT_PASSWORD: root
ports:
- "8888:3306"
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- name: Set up SLURM
uses: koesterlab/setup-slurm-action@v1
- name: Setup Mambaforge
uses: conda-incubator/setup-miniconda@v2
with:
miniforge-variant: Mambaforge
miniforge-version: latest
use-mamba: true
activate-environment: slurm_sweeps
- name: Check out repo
uses: actions/checkout@v4
- name: Get Date for Conda cache
id: get-date
run: echo "today=$(/bin/date -u '+%Y%m%d')" >> $GITHUB_OUTPUT
shell: bash
- name: Cache Conda env
uses: actions/cache@v3
env:
CACHE_NUMBER: 0
with:
path: ${{ env.CONDA }}/envs
key:
conda-${{
runner.os }}-${{
steps.get-date.outputs.today }}-${{
hashFiles('environment.yml') }}-${{
env.CACHE_NUMBER }}
id: cache
- name: Update environment
run: mamba env update -n slurm_sweeps -f environment.yml
if: steps.cache.outputs.cache-hit != 'true'
- name: Running tests
run: pytest --cov=slurm_sweeps
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
release:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'release' }}
needs: tests
steps:
- uses: actions/checkout@v4
- name: Set up Pythonh
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build
- name: Publish to TestPyPi
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.TESTPYPI_API_TOKEN }}
repository-url: https://test.pypi.org/legacy/
- name: Test installing
run: |
pip install --index-url https://test.pypi.org/simple --no-deps slurm-sweeps
- name: Publish to PyPi
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}