Skip to content

Commit

Permalink
CI: schedule export & default to overwrite=false
Browse files Browse the repository at this point in the history
refs #1
  • Loading branch information
dhimmel committed Oct 12, 2021
1 parent d74d2cf commit dab8324
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 8 deletions.
46 changes: 40 additions & 6 deletions .github/workflows/export.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
name: Export
on:
schedule:
# https://crontab.guru/#05_11_*_*_2
- cron: '05 11 * * 2'
workflow_dispatch:
inputs:
release:
description: 'Ensembl release number'
description: 'Ensembl release number (e.g. 104 or latest)'
required: true
default: '104'
overwrite:
description: 'Overwrite output on an existing branch (true or false).'
required: true
default: 'false'
jobs:
export:
runs-on: ubuntu-latest
Expand All @@ -14,22 +21,49 @@ jobs:
uses: actions/checkout@v2
- name: Setup dependencies
uses: ./.github/actions/setup
- name: Set parameters
id: params
shell: bash
run: |
ENSEMBL_RELEASE=${{ github.event.inputs.release || 'latest' }}
# update latest to release number
ENSEMBL_RELEASE=$(poetry run python src/ensembl_genes.py ensembl_release --release="$ENSEMBL_RELEASE")
echo "Setting parameter release=$ENSEMBL_RELEASE"
echo "::set-output name=release::$ENSEMBL_RELEASE"
OUTPUT_EXISTS="true"
git ls-remote --exit-code origin output-$ENSEMBL_RELEASE || OUTPUT_EXISTS="false"
echo "output-$ENSEMBL_RELEASE branch exists on origin: $OUTPUT_EXISTS"
echo "::set-output name=output_exists::$OUTPUT_EXISTS"
OVERWRITE=${{ github.event.inputs.overwrite || 'false' }}
echo "Setting parameter overwrite=$OVERWRITE"
echo "::set-output name=overwrite::$OVERWRITE"
EXPORT="false"
if [[ $OUTPUT_EXISTS = "false" || $OVERWRITE = "true" ]]; then
EXPORT="true"
fi
echo "Setting parameter export=$EXPORT"
echo "::set-output name=export::$EXPORT"
- name: Extract tables
id: extract
run: poetry run python src/ensembl_genes.py all --release=${{ github.event.inputs.release }}
if: steps.params.outputs.overwrite == 'true'
run: poetry run python src/ensembl_genes.py all --release=${{ steps.params.outputs.release }}
- name: Output artifact
# upload outputs to artifact only when the extraction fails
if: always() && steps.extract.outcome == 'failure'
uses: actions/upload-artifact@v2
with:
name: failed-output-${{ github.event.inputs.release }}
path: output/${{ github.event.inputs.release }}
name: failed-output-${{ steps.params.outputs.release }}
path: output/${{ steps.params.outputs.release }}
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
if: steps.params.outputs.overwrite == 'true'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_branch: output-${{ github.event.inputs.release }}
publish_dir: output/${{ github.event.inputs.release }}
publish_branch: output-${{ steps.params.outputs.release }}
publish_dir: output/${{ steps.params.outputs.release }}
# Won't actually enable jekyll because we're not using GitHub Pages.
# https://github.com/peaceiris/actions-gh-pages/issues/660
enable_jekyll: true
3 changes: 3 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ name: Test
on:
push:
pull_request:
schedule:
# https://crontab.guru/#57_6_*_*_1
- cron: '57 6 * * 1'
jobs:
test:
runs-on: ubuntu-latest
Expand Down
4 changes: 2 additions & 2 deletions src/ensembl_genes.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ def get_latest_ensembl_release() -> str:
return ensembl_release


def check_ensembl_release(release: str) -> str:
def check_ensembl_release(release: str = "latest") -> str:
"""
Check that ensembl release is properly formatted, like '104'.
If release is 'latest', get latest release using bioversions.
Expand Down Expand Up @@ -614,6 +614,6 @@ def export_all(cls, release: str = "latest") -> None:
"datasets": Commands.export_datasets,
"notebooks": Commands.export_notebooks,
"all": Commands.export_all,
"latest_release": get_latest_ensembl_release,
"ensembl_release": check_ensembl_release,
}
fire.Fire(commands)

0 comments on commit dab8324

Please sign in to comment.