Skip to content

Commit

Permalink
Update CI workflows (#105)
Browse files Browse the repository at this point in the history
  • Loading branch information
andersy005 authored Feb 2, 2022
1 parent 6bcc105 commit 50f8d14
Show file tree
Hide file tree
Showing 7 changed files with 150 additions and 29 deletions.
44 changes: 18 additions & 26 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,59 +1,51 @@
name: CI
on:
push:
branches:
- main
pull_request:
schedule:
- cron: '0 0 * * *' # Daily “At 00:00”
workflow_dispatch: # allows you to trigger manually

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
pre-job:
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@master
with:
concurrent_skipping: 'same_content'
skip_after_successful_duplicate: 'false'
do_not_skip: '["pull_request", "workflow_dispatch", "schedule"]'
paths_ignore: '["**/docs/**"]'
build:
needs: pre-job
if: ${{ needs.pre-job.outputs.should_skip != 'true' }}
name: python-${{ matrix.python-version }}
if: github.repository == 'NCAR/ecgtools'
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
strategy:
fail-fast: false
matrix:
python-version: ['3.7', '3.8', '3.9']
python-version: ['3.7', '3.8', '3.9', '3.10']
steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: conda-incubator/setup-miniconda@v2
with:
channels: conda-forge,nodefaults
mamba-version: '*'
channels: conda-forge
channel-priority: strict
activate-environment: ecgtools-dev
auto-update-conda: false
python-version: ${{ matrix.python-version }}
mamba-version: '*'
use-mamba: true
miniforge-variant: Mambaforge
environment-file: ci/environment.yml

- name: Set up conda environment
- name: Install ecgtools
run: |
python -m pip install -e .
python -m pip install -e . --no-deps --force-reinstall
conda list
- name: Run Tests
run: |
python -m pytest --cov=./ --cov-report=xml --verbose
python -m pytest
- name: Upload code coverage to Codecov
uses: codecov/[email protected]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
name: Build and Upload ecgtools to PyPI
name: Build distribution
on:
release:
types:
- published
push:

jobs:
build-artifacts:
Expand Down Expand Up @@ -60,6 +61,13 @@ jobs:
ls -ltrh
ls -ltrh dist
- name: Verify the built dist/wheel is valid
if: github.event_name == 'push'
run: |
python -m pip install --upgrade pip
python -m pip install dist/ecgtools*.whl
python -c "import ecgtools; print(ecgtools.__version__)"
upload-to-pypi:
needs: test-built-dist
if: github.event_name == 'release'
Expand Down
95 changes: 95 additions & 0 deletions .github/workflows/upstream-dev-ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
name: Upstream CI
on:
push:
branches:
- main
schedule:
- cron: '0 0 * * *' # Daily “At 00:00” UTC
workflow_dispatch: # allows you to trigger the workflow run manually

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
upstream-dev:
name: upstream-dev
runs-on: ubuntu-latest
if: github.repository == 'NCAR/ecgtools'
defaults:
run:
shell: bash -l {0}
strategy:
fail-fast: false
matrix:
python-version: ['3.10']
steps:
- uses: actions/checkout@v2
- uses: conda-incubator/setup-miniconda@v2
id: conda
with:
channels: conda-forge,nodefaults
channel-priority: strict
activate-environment: ecgtools-dev
auto-update-conda: false
python-version: ${{ matrix.python-version }}
environment-file: ci/environment-upstream-dev.yml
mamba-version: '*'
use-mamba: true
miniforge-variant: Mambaforge

- name: Install ecgtools
id: install
run: |
python -m pip install -e . --no-deps --force-reinstall
conda list
- name: Run Tests
id: test
run: |
python -m pytest
- name: Report Status
if: |
always()
&& (steps.conda.outcome != 'success' || steps.install.outcome != 'success' || steps.install.outcome != 'success')
uses: actions/github-script@v5
with:
script: |
const title = '⚠️ Upstream CI Failed ⚠️'
const creator = 'github-actions[bot]'
const issueLabel = 'CI'
const workflow_url = `https://github.com/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}`
const issue_body = `[Workflow Run URL](${workflow_url})\n\n`
let foundIssue = false
const issues = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
})
for (let issue of issues.data) {
if (
issue.user.login === creator &&
issue.state === 'open' &&
issue.labels.some((label) => label.name === issueLabel)
) {
github.rest.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
body: issue_body,
})
core.info(`Updated an existing issue: ${issue.number}.`)
foundIssue = true
break
}
}
if (!foundIssue) {
await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: title,
body: issue_body,
labels: [issueLabel],
})
core.info('Opened a new issue')
}
File renamed without changes.
25 changes: 25 additions & 0 deletions ci/environment-upstream-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: ecgtools-dev
channels:
- conda-forge
- nodefaults
dependencies:
- cf_xarray
- codecov
- intake-esm
- joblib
- nbsphinx
- netcdf4
- numpydoc
- pip
- pre-commit
- pydantic
- pytest
- pytest-cov
- pytest-sugar
- pytest-xdist
- pyyaml
- typer
- xarray
- pip:
- git+https://github.com/xarray-contrib/cf-xarray
- git+https://github.com/intake/intake-esm
3 changes: 2 additions & 1 deletion ci/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ channels:
- nodefaults
dependencies:
- cf_xarray
- codecov
- intake-esm
- joblib
- nbsphinx
Expand All @@ -20,3 +19,5 @@ dependencies:
- pyyaml
- typer
- xarray
- pip:
- git+https://github.com/intake/intake-esm
2 changes: 1 addition & 1 deletion readthedocs.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
version: 2
conda:
environment: docs/environment.yml
environment: ci/environment-docs.yml
build:
os: 'ubuntu-20.04'
tools:
Expand Down

0 comments on commit 50f8d14

Please sign in to comment.