Skip to content

Commit

Permalink
[test branch] Test osx-arm64 merging to mock target branch (2) (#46961)
Browse files Browse the repository at this point in the history
* skip remaining steps if no matching platform

* fix step syntax

* fix variable syntax

* bump version

* additional logging

* standardize name

* test skip feature

* fix syntax

* readd platform

* remove extra space

* try to fix brew error

* bump version

* check permission

* make the dir

* remove caching

* remove caching

* remove dry run
  • Loading branch information
aliciaaevans authored Apr 4, 2024
1 parent 750e15b commit 6f1f1db
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 45 deletions.
47 changes: 47 additions & 0 deletions .github/check-for-additional-platforms.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/bash

# Check to see if any changed recipes have specified the key
# extra:additional-platforms, and if so, if they match the platform of the
# currently-running machine.

# arguments
git_range=$1
job_name=$2

# Download ARM version of yq
yq_platform=$(uname)
yq_arch=$(uname -m)
[[ $yq_arch = "aarch64" ]] && yq_arch="arm64"
mkdir -p ${HOME}/bin
wget https://github.com/mikefarah/yq/releases/latest/download/yq_${yq_platform}_${yq_arch} -O ${HOME}/bin/yq
chmod +x ${HOME}/bin/yq

# Find recipes changed from this merge
files=`git diff --name-only --diff-filter AMR ${git_range} | grep -E 'meta.yaml$' `
build=0

for file in $files; do
echo $file
# To create a properly-formatted yaml that yq can parse, comment out jinja2
# variable setting with {% %} and remove variable use with {{ }}.
additional_platforms=$(cat $file \
| sed -E 's/(.*)\{%(.*)%\}(.*)/# \1\2\3/g' \
| tr -d '{{' | tr -d '}}' \
| ${HOME}/bin/yq '.extra.additional-platforms[]')
# Check if any additional platforms match this job
for additional_platform in $additional_platforms; do
if [ "${GITHUB_JOB}" = "${job_name}-${additional_platform}" ]
then
echo "Found at least one recipe for ${job_name}-${additional_platform}"
build=1
break
fi
done
done

# If no changed recipes apply to this platform, skip remaining steps
if [[ build -lt 1 ]]
then
echo "No recipes using this platform, skipping rest of job."
echo "skip_build=true" >> $GITHUB_OUTPUT
fi
32 changes: 12 additions & 20 deletions .github/workflows/PR-arm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ concurrency:
group: build-${{ github.event.pull_request.number || github.head_ref }}
cancel-in-progress: true
jobs:
build-osx-arm:
name: osx-arm64 Tests
build_and_test-osx-arm64:
name: build_and_test-osx-arm64
runs-on: macOS-14 # M1
strategy:
fail-fast: true
Expand All @@ -17,39 +17,29 @@ jobs:
with:
fetch-depth: 0

# TODO: bail if there's no osx-arm64 recipes
# - run:
# name: Check for Additional Platforms
# command: ./.circleci/check-for-additional-platforms.sh "origin/master...HEAD" "build_and_test"
# bail if there's no osx-arm64 recipes
- name: Check for Additional Platforms
id: additional_platforms
run: ./.github/check-for-additional-platforms.sh "origin/master...HEAD" "build_and_test"

- name: set path
run: echo "/opt/mambaforge/bin" >> $GITHUB_PATH

- name: Fetch conda install script
if: steps.additional_platforms.outputs.skip_build != 'true'
run: |
wget https://raw.githubusercontent.com/bioconda/bioconda-common/master/{install-and-set-up-conda,configure-conda,common}.sh
- name: Restore cache
id: cache
uses: actions/cache@v4
with:
path: /opt/mambaforge
key: ${{ runner.os }}--master--${{ hashFiles('install-and-set-up-conda.sh', 'common.sh', 'configure-conda.sh') }}

- name: Set up bioconda-utils
if: steps.cache.outputs.cache-hit != 'true'
if: steps.additional_platforms.outputs.skip_build != 'true'
run: bash install-and-set-up-conda.sh

# This script can be used to reconfigure conda to use the right channel setup.
# This has to be done after the cache is restored, because
# the channel setup is not cached as it resides in the home directory.
# We could use a system-wide (and therefore cached) channel setup,
# but mamba does not support that at the time of implementation
# (it ignores settings made with --system).
- name: Configure conda
if: steps.additional_platforms.outputs.skip_build != 'true'
run: bash configure-conda.sh

- name: Build and Test
if: steps.additional_platforms.outputs.skip_build != 'true'
env:
# Mimic circleci
OSTYPE: "darwin"
Expand Down Expand Up @@ -78,6 +68,7 @@ jobs:
--git-range origin/"$GITHUB_BASE_REF" HEAD
- name: Prepare artifacts
if: steps.additional_platforms.outputs.skip_build != 'true'
run: |
(
rm -rf /tmp/artifacts
Expand All @@ -90,6 +81,7 @@ jobs:
) || true
- name: Archive packages
if: steps.additional_platforms.outputs.skip_build != 'true'
uses: actions/upload-artifact@v4
with:
name: osx-arm64-packages
Expand Down
37 changes: 13 additions & 24 deletions .github/workflows/master-arm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ on:
- target-for-arm-osx

jobs:
build-upload-osx-arm:
name: osx-arm64 Upload
build_and_upload-osx-arm64:
name: build_and_upload-osx-arm64
if: github.repository == 'bioconda/bioconda-recipes'
runs-on: macOS-14 # M1
strategy:
Expand All @@ -17,39 +17,30 @@ jobs:
with:
fetch-depth: 0

# TODO: bail if there's no osx-arm64 recipes
# - run:
# name: Check for Additional Platforms
# command: ./.circleci/check-for-additional-platforms.sh "${CIRCLE_SHA1}~1 ${CIRCLE_SHA1}" "build_and_upload"
# bail if there's no osx-arm64 recipes
- name: Check for Additional Platforms
id: additional_platforms
run: ./.github/check-for-additional-platforms.sh "${GITHUB_SHA}~1 ${GITHUB_SHA}" "build_and_upload"

- name: set path
run: echo "/opt/mambaforge/bin" >> $GITHUB_PATH
run: |
echo "/opt/mambaforge/bin" >> $GITHUB_PATH
- name: Fetch conda install script
if: steps.additional_platforms.outputs.skip_build != 'true'
run: |
wget https://raw.githubusercontent.com/bioconda/bioconda-common/master/{install-and-set-up-conda,configure-conda,common}.sh
- name: Restore cache
id: cache
uses: actions/cache@v4
with:
path: /opt/mambaforge
key: ${{ runner.os }}--master--${{ hashFiles('install-and-set-up-conda.sh', 'common.sh', 'configure-conda.sh') }}

- name: Set up bioconda-utils
if: steps.cache.outputs.cache-hit != 'true'
if: steps.additional_platforms.outputs.skip_build != 'true'
run: bash install-and-set-up-conda.sh

# This script can be used to reconfigure conda to use the right channel setup.
# This has to be done after the cache is restored, because
# the channel setup is not cached as it resides in the home directory.
# We could use a system-wide (and therefore cached) channel setup,
# but mamba does not support that at the time of implementation
# (it ignores settings made with --system).
- name: Configure conda
if: steps.additional_platforms.outputs.skip_build != 'true'
run: bash configure-conda.sh

- name: Build and Upload
if: steps.additional_platforms.outputs.skip_build != 'true'
env:
QUAY_LOGIN: ${{ secrets.QUAY_LOGIN }}
QUAY_OAUTH_TOKEN: ${{ secrets.QUAY_OAUTH_TOKEN }}
Expand All @@ -74,6 +65,4 @@ jobs:
--repo bioconda/bioconda-recipes \
--git-range ${GITHUB_SHA}~1 ${GITHUB_SHA} \
--fallback build \
--artifact-source github-actions \
--dryrun
# TODO: remove dry-run after testing
--artifact-source github-actions
2 changes: 1 addition & 1 deletion recipes/test/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
package:

name: test
version: 0.2
version: 0.4

source:
url: https://github.com/lh3/seqtk/archive/v1.4.tar.gz
Expand Down

0 comments on commit 6f1f1db

Please sign in to comment.