Skip to content

Nightly

Nightly #4

Workflow file for this run

name: Nightly
on:
schedule:
- cron: "0 2 * * *" # run at 2 AM UTC
workflow_dispatch:
inputs:
debug_enabled:
description: 'Run the build with tmate debugging enabled'
type: boolean
required: false
default: false
linux:
description: 'Run build on Linux'
type: boolean
required: false
default: true
windows:
description: 'Run build on Windows'
type: boolean
required: false
default: true
macos:
description: 'Run build on macOS'
type: boolean
required: false
default: true
repository_dispatch:
types: nightly-build
defaults:
run:
shell: bash -l {0}
env:
GITHUB_TOKEN: ${{ github.token }}
jobs:
build-nightly:
name: Build
needs: [check-assets, generate-matrix]
if: ${{ github.event_name == 'workflow_dispatch' || needs.check-assets.outputs.needs-build == 'true' }}
runs-on: ${{ matrix.os }}-latest
strategy:
matrix:
python-version: [3.9]
os: ${{ fromJSON(needs.generate-matrix.outputs.os) }}
fail-fast: false
steps:
- uses: actions/checkout@v3
- name: Cache conda
id: cache
if: ${{ !env.ACT }}
uses: actions/cache@v3
env:
# Increase this value to reset cache if environment.yml has not changed
CACHE_NUMBER: 2
with:
path: |
~/conda_pkgs_dir
~/conda-env-explicit.txt
key: ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{ hashFiles('environment*.yml') }}
- name: Check Cache
id: check-cache
uses: ./.github/actions/get_environment
with:
cache-hit: ${{ steps.cache.outputs.cache-hit }}
python-version: ${{ matrix.python-version }}
- name: Set up Python
uses: conda-incubator/setup-miniconda@v2
with:
miniforge-variant: Mambaforge
miniforge-version: latest
activate-environment: metgem
mamba-version: "*"
channel-priority: strict
channels: conda-forge,metgem,bioconda
python-version: ${{ steps.check-cache.outputs.python-version }}
environment-file: ${{ steps.check-cache.outputs.environment }}
use-only-tar-bz2: true # IMPORTANT: This needs to be set for caching to work properly!
- run: |
conda info
conda list
conda config --show-sources
conda config --show
- name: Install Build Dependencies
uses: ./.github/actions/install_build_dependencies
with:
pip-only: ${{ steps.check-cache.outputs.explicit }}
- name: Fetch tags
if: ${{ !env.ACT }}
run: git fetch --prune --unshallow # This is important to get version from versioneer
- name: Build
id: build
uses: ./.github/actions/build
- name: Run Tests
id: tests
uses: ./.github/actions/tests
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
if: ${{ failure() && !env.ACT && github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled }}
with:
limit-access-to-actor: true
- name: Upload Tests Artifacts
if: ${{ always() && !env.ACT }}
uses: actions/upload-artifact@v3
with:
name: tests
path: ${{ steps.tests.outputs.log }}
- name: Deploy Nightly
if: ${{ !env.ACT }}
uses: WebFreak001/[email protected]
with:
upload_url: https://uploads.github.com/repos/${{ github.repository }}/releases/33563969/assets{?name,label}
release_id: 33563969
asset_path: metgem_packaging/${{ steps.build.outputs.asset-name }}
asset_name: ${{ steps.build.outputs.asset-basename }}-$$.${{ steps.build.outputs.asset-ext }}
asset_content_type: ${{ steps.build.outputs.asset-mimetype }}
max_releases: 6
# Check that current commit does not have a nightly build asset uploaded yet
check-assets:
runs-on: ubuntu-latest
outputs:
needs-build: ${{ steps.assets.outputs.needs-build }}
steps:
- name: Check existing assets
id: assets
run: |
hash=${{ github.sha }}
hash=${hash::6}
names=( $(curl -sL https://api.github.com/repos/${{ github.repository }}/releases/33563969/assets | jq -r '.[].name') )
needs_build='true'
if [ "${{ github.event_name }}" == "repository_dispatch" ] || [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
echo "[WARNING] Nightly workflow triggered manually"
else
for name in "${names[@]}"
do
basename=${name##*-};
if [ "${basename%.*}" == "$hash" ]; then
echo "[WARNING] Commit already built, skipping build"
needs_build='false'
break
fi
done
fi
echo "needs-build=$needs_build" >> $GITHUB_OUTPUT
generate-matrix:
runs-on: ubuntu-latest
name: "Generate matrix job specs"
outputs:
os: ${{ steps.generate-matrix.outputs.os }}
steps:
- name: generate-matrix
id: generate-matrix
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
os=()
if [ "${{ github.event.inputs.linux}}" == "true" ]; then
os+=('ubuntu')
fi
if [ "${{ github.event.inputs.windows}}" == "true" ]; then
os+=('windows')
fi
if [ "${{ github.event.inputs.macos }}" == "true" ]; then
os+=('macos')
fi
os=$(printf ', "%s"' "${os[@]}")
os="[${os:2}]"
echo "[INFO] OS selected: $os"
echo "os=$os" >> $GITHUB_OUTPUT
else
echo 'os=["ubuntu","windows","macos"]' >> $GITHUB_OUTPUT
fi
update-nightly-tag:
needs: build-nightly
runs-on: ubuntu-latest
steps:
- name: Update Nightly tag
uses: richardsimko/update-tag@v1
with:
tag_name: nightly