2023.7 community staged #449
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: ci-build-metapackage | |
on: | |
workflow_dispatch: {} | |
pull_request: | |
branches: [main] | |
paths: | |
- 20*.*/staged/**/* | |
jobs: | |
conf: | |
runs-on: ubuntu-latest # this job is always run on linux | |
outputs: | |
epochs: ${{ steps.set-vars.outputs.epochs }} | |
distros: ${{ steps.set-vars.outputs.distros }} | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 2 | |
- uses: tj-actions/changed-files@v19 | |
id: changed | |
- name: set-vars | |
id: set-vars | |
run: | | |
# Parse the git changes to figure out which epoch triggered this workflow. | |
CHANGED="${{ steps.changed.outputs.all_changed_files }}" | |
EPOCHS=$(python .github/workflows/bin/determine.py --epoch "$CHANGED") | |
echo "::set-output name=epochs::$EPOCHS" | |
DISTROS=$(python .github/workflows/bin/determine.py --distro "$CHANGED") | |
echo "::set-output name=distros::$DISTROS" | |
integrate: | |
runs-on: ${{ matrix.platform }} | |
needs: [conf] | |
strategy: | |
matrix: | |
epoch: ${{ fromJson(needs.conf.outputs.epochs) }} | |
distro: ${{ fromJson(needs.conf.outputs.distros) }} | |
platform: | |
- ubuntu-latest | |
- macos-latest | |
env: | |
BUILD_DIR: ./build/ | |
TEMPLATE_PATH: ${{ matrix.epoch }}/staged/${{ matrix.distro }}/ | |
Q2_CHANNEL: https://packages.qiime2.org/qiime2/${{ matrix.epoch }}/tested/ | |
steps: | |
- name: set host helper env vars | |
run: | | |
case "${{ matrix.platform }}" in | |
'ubuntu-latest') echo 'CONDA_PLATFORM=linux' >> $GITHUB_ENV ;; | |
'macos-latest') echo 'CONDA_PLATFORM=osx' >> $GITHUB_ENV ;; | |
esac | |
- uses: actions/checkout@v3 | |
- uses: ./.github/actions/configure-conda | |
- name: template recipe | |
run: | | |
source "$CONDA/etc/profile.d/conda.sh" | |
conda activate base | |
pip install 'jinja2' pyyaml | |
python .github/workflows/bin/template.py $TEMPLATE_PATH | |
- name: debug recipe | |
run: cat $TEMPLATE_PATH/meta.yaml | |
- name: build recipe | |
run: | | |
source "$CONDA/etc/profile.d/conda.sh" | |
conda activate base | |
sudo conda mambabuild \ | |
-c $Q2_CHANNEL \ | |
-c conda-forge \ | |
-c bioconda \ | |
-c defaults \ | |
--override-channels \ | |
--output-folder $BUILD_DIR \ | |
--no-anaconda-upload \ | |
$TEMPLATE_PATH | |
- name: upload build artifact | |
uses: actions/upload-artifact@v2 | |
with: | |
name: ${{ matrix.distro }}-${{ env.CONDA_PLATFORM }} | |
path: ${{ env.BUILD_DIR }}/*/** | |
- name: phone home | |
env: | |
PACKAGE_NAME: qiime2-${{ matrix.distro }} | |
LIBRARY_TOKEN: ${{ secrets.LIBRARY_TOKEN }} | |
run: | | |
source "$CONDA/etc/profile.d/conda.sh" | |
conda activate base | |
phone_home=$(yq ".meta.phone_home" $TEMPLATE_PATH/data.yaml) | |
if [ "$phone_home" = "false" ] | |
then | |
echo "skipping library upload due to disabled phone_home" | |
exit 0 | |
fi | |
metapackage_version=$(sudo conda search -c $BUILD_DIR $PACKAGE_NAME --json | \ | |
jq --arg PKG "$PACKAGE_NAME" -r '.[$PKG][0].version') | |
package_versions=$(python .github/workflows/bin/integration_versions.py $TEMPLATE_PATH) | |
resp=$(curl \ | |
--silent \ | |
--include \ | |
--data-urlencode "token=$LIBRARY_TOKEN" \ | |
--data-urlencode "version=$metapackage_version" \ | |
--data-urlencode "package_versions=$package_versions" \ | |
--data "run_id=$GITHUB_RUN_ID" \ | |
--data "distro=${{ matrix.distro }}" \ | |
--data "epoch=${{ matrix.epoch }}" \ | |
--data "artifact_name=${{ matrix.distro }}-${{ env.CONDA_PLATFORM }}" \ | |
--data "pr_number=${{ github.event.pull_request.number }}" \ | |
--header "Content-Type: application/x-www-form-urlencoded" \ | |
--request POST \ | |
https://library.qiime2.org/api/v1/packages/stage/ | |
) | |
code=$(echo $resp | grep HTTP | awk '{print $2}') | |
if [[ $code -ne 200 ]] | |
then | |
echo "whoops" | |
echo $resp | |
exit 1 | |
fi |