diff --git a/.travis-output.py b/.ci-output.py similarity index 100% rename from .travis-output.py rename to .ci-output.py diff --git a/README.md b/README.md index d4bd706..f00a5f0 100644 --- a/README.md +++ b/README.md @@ -4,17 +4,12 @@ Travis scripts for Litex-Hub/litex-conda-(compilers|eda|misc|prog) . This repository is not meant to be used on its own, but as submodule for above repositories. -## Setting up Travis for your own fork +## Setting up Github Actions for your own fork -To use any of the litex-conda-* repositories in your own fork with Travis you must meet the following requirements: +To use any of the litex-conda-* repositories in Github Actions you must meet the following requirements: -* enable Travis for your repository * create an account on https://anaconda.org/ * create an access token on https://anaconda.org/{your-account}/settings/access -* visit https://travis-ci.com/github/{your-account}/litex-conda-{suffix}/settings -* add two environment variables: +* follow https://docs.github.com/en/free-pro-team@latest/actions/reference/encrypted-secrets#creating-encrypted-secrets-for-an-environment to add two encrypted secrets: * `ANACONDA_USER` - set to your anaconda username * `ANACONDA_TOKEN` - set to the value of the token you created -* remember to **disable** the `Display value in build log` option for `ANACONDA_TOKEN` -* create a daily or weekly Cron Job on the same settings page, to start on the master branch - * this will ensure removal of temporary labels on your Anaconda account (they are created during the build) diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..779497e --- /dev/null +++ b/action.yml @@ -0,0 +1,29 @@ +name: 'Package build' +description: 'Build a package' +runs: + using: "composite" + steps: + - name: build + run: | + if [ $SKIP ]; then + exit 0; + fi + if [ $OS_NAME = "windows" ]; then + export PATH="$PATH:/c/ProgramData/Chocolatey/bin/" + export PATH="$PATH:/c/Program Files/Git/usr/bin/" + fi + source .github/scripts/common.sh + bash .github/scripts/download_sdk.sh + bash .github/scripts/install.sh + set -x + if [ $SCRIPT ]; then + bash $SCRIPT + else + bash .github/scripts/script.sh + fi + if [ $? -eq 0 ]; then + source .github/scripts/after_success.sh + else + source .github/scripts/after_failure.sh + fi + shell: bash diff --git a/after_failure.sh b/after_failure.sh index 8258bb6..4fc0337 100755 --- a/after_failure.sh +++ b/after_failure.sh @@ -1,9 +1,9 @@ #!/bin/bash -source $TRAVIS_BUILD_DIR/.travis/common.sh +source $GITHUB_WORKSPACE/.github/scripts/common.sh -# Close the after_failure fold travis has created already. -travis_fold end after_failure +# Close the after_failure fold +echo ::endgroup:: $SPACER @@ -16,16 +16,6 @@ end_section "failure.tail" $SPACER -#COUNT=0 -#for i in $(find $BASE_PATH -name config.log); do -# start_section "failure.log.$COUNT" "${RED}Failure output $i...${NC}" -# cat $i -# end_section "failure.log.$COUNT" -# COUNT=$((COUNT+1)) -#done -# -#$SPACER - start_section "failure.log.full" "${RED}Failure output.log...${NC}" cat /tmp/output.log end_section "failure.log.full" diff --git a/after_success.sh b/after_success.sh index 4fff6c0..9ea1e0c 100755 --- a/after_success.sh +++ b/after_success.sh @@ -1,10 +1,10 @@ #!/bin/bash -source ./.travis/common.sh +source $GITHUB_WORKSPACE/.github/scripts/common.sh set -e -# Close the after_success fold travis has created already. -travis_fold end after_success +# Close the after_success fold +echo ::endgroup:: if [[ $UPLOAD == "no-upload" ]]; then echo "Job without upload..." @@ -12,18 +12,18 @@ else echo "Job with Conda upload..." $SPACER - # Travis will not expose the ANACONDA_TOKEN var for pull requests coming from other forks than the original one if [ x$ANACONDA_TOKEN != x ]; then # `anaconda-client` is installed in the `base` environment conda activate base start_section "package.upload" "${GREEN}Package uploading...${NC}" # Test `anaconda` with ANACONDA_TOKEN before uploading - source $TRAVIS_BUILD_DIR/.travis/test_anaconda.sh - anaconda -t $ANACONDA_TOKEN upload --no-progress --user $ANACONDA_USER --label travis-${TRAVIS_PULL_REQUEST_BRANCH:-$TRAVIS_BRANCH}-$TRAVIS_BUILD_ID $CONDA_OUT + source $GITHUB_WORKSPACE/.github/scripts/test_anaconda.sh + branch="$(git rev-parse --abbrev-ref HEAD)" + anaconda -t $ANACONDA_TOKEN upload --force --no-progress --user $ANACONDA_USER --label ci-$branch-$GITHUB_RUN_ID $CONDA_OUT end_section "package.upload" else - echo "ANACONDA_TOKEN not found. Please consult README of litex-conda-ci for details on setting up Travis tests properly." + echo "ANACONDA_TOKEN not found. Please consult README of litex-conda-ci for details on setting up tests properly." echo "Packages cannot be uploaded when tests are running for cross-repository Pull Requests." fi diff --git a/before_cache.sh b/before_cache.sh deleted file mode 100755 index feff250..0000000 --- a/before_cache.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -source ./.travis/common.sh -set -e - -# Close the after_success.1 fold travis has created already. -travis_fold end before_cache - -start_section "conda.clean.1" "${GREEN}Clean status...${NC}" -#conda clean -s --dry-run -end_section "conda.clean.1" - -start_section "conda.clean.2" "${GREEN}Cleaning...${NC}" -conda build purge -end_section "conda.clean.2" - -start_section "conda.clean.3" "${GREEN}Clean status...${NC}" -#conda clean -s --dry-run -end_section "conda.clean.3" diff --git a/cleanup-anaconda.sh b/cleanup-anaconda.sh old mode 100644 new mode 100755 index 21fb1e5..5155752 --- a/cleanup-anaconda.sh +++ b/cleanup-anaconda.sh @@ -1,7 +1,9 @@ #!/bin/bash +source $GITHUB_WORKSPACE/.github/scripts/common.sh # `for ... in $(anaconda ...` fails silently if there's any problem with anaconda -source $TRAVIS_BUILD_DIR/.travis/test_anaconda.sh +source $GITHUB_WORKSPACE/.github/scripts/test_anaconda.sh +set -x #if the timestamp is older than one week, remove the whole label ago="7 days ago" @@ -11,9 +13,9 @@ limit_date=$(date $DATE_SWITCH "$ago" +'%s%N' | cut -b1-13) echo "Will remove labels older than $limit_date timestamp" -for label in $(anaconda -t $ANACONDA_TOKEN label --list -o litex-hub 2>&1 | grep ' + ' | cut -f2 -d1+) +for label in $(anaconda -t $ANACONDA_TOKEN label --list -o litex-hub 2>&1 | grep ' + ' | cut -f2 -d+) do - if [[ $label != travis* ]] + if [[ $label != ci* ]] then continue fi diff --git a/common.sh b/common.sh index 6346dba..cf81475 100644 --- a/common.sh +++ b/common.sh @@ -9,15 +9,9 @@ NC='\033[0m' # No Color SPACER="echo -e ${GRAY} - ${NC}" -export -f travis_nanoseconds -export -f travis_fold -export -f travis_time_start -export -f travis_time_finish +CI_MAX_TIME=50 -TRAVIS_MAX_TIME=50 - -# Override default travis_wait to pipe the output -travis_wait() { +ci_wait() { local timeout="${1}" if [[ "${timeout}" =~ ^[0-9]+$ ]]; then @@ -27,12 +21,12 @@ travis_wait() { fi local cmd=("${@}") - local log_file="travis_wait_${$}.log" + local log_file="ci_wait_${$}.log" "${cmd[@]}" & local cmd_pid="${!}" - travis_jigger "${!}" "${timeout}" "${cmd[@]}" & + ci_jigger "${!}" "${timeout}" "${cmd[@]}" & local jigger_pid="${!}" local result @@ -53,8 +47,7 @@ travis_wait() { return "${result}" } -# Override default travis_jigger to print invisible character to keep build alive -travis_jigger() { +ci_jigger() { local cmd_pid="${1}" shift local timeout="${1}" @@ -74,10 +67,10 @@ travis_jigger() { kill -9 "${cmd_pid}" } -if [ $TRAVIS_OS_NAME = 'osx' ]; then - DATE_SWITCH="-r " +if [ $OS_NAME = 'osx' ]; then + export DATE_SWITCH="-r " else - DATE_SWITCH="--date=@" + export DATE_SWITCH="--date=@" fi if [ -z "$DATE_STR" ]; then export DATE_TS="$(git log --format=%ct -n1)" @@ -88,34 +81,32 @@ if [ -z "$DATE_STR" ]; then fi function start_section() { - travis_fold start "$1" - travis_time_start + echo "::group::$1" echo -e "${PURPLE}${PACKAGE}${NC}: - $2${NC}" echo -e "${GRAY}-------------------------------------------------------------------${NC}" } function end_section() { echo -e "${GRAY}-------------------------------------------------------------------${NC}" - travis_time_finish - travis_fold end "$1" + echo ::endgroup:: } -# Disable this warning; -# xxxx/conda_build/environ.py:377: UserWarning: The environment variable -# 'TRAVIS' is being passed through with value 0. If you are splitting -# build and test phases with --no-test, please ensure that this value is -# also set similarly at test time. export PYTHONWARNINGS=ignore::UserWarning:conda_build.environ export BASE_PATH="/tmp/really-long-path" mkdir -p "$BASE_PATH" -if [ $TRAVIS_OS_NAME = 'windows' ]; then +if [ $OS_NAME = 'windows' ]; then export CONDA_PATH='/c/tools/miniconda3' export PATH=$CONDA_PATH/Scripts/:$CONDA_PATH/:$PATH # It is much shorter than '$PWD/workdir/conda-env' which in the end (+conda-bld/...) # causes some build paths to exceed 255 chars (e.g. during prjtrellis building) - export CONDA_ENV='/c/Users/travis/conda-env' + RUNNER_DIR='/c/Users/runner/' + if [ ! -d "$RUNNER_DIR" ]; then + mkdir "$RUNNER_DIR" + fi + + export CONDA_ENV="$RUNNER_DIR/conda-env" if [ -d 'workdir/conda-env' ]; then mv 'workdir/conda-env' "$CONDA_ENV" fi @@ -141,9 +132,8 @@ if [ -d "workdir/recipe" ]; then export CONDA_BUILD_ARGS="$EXTRA_BUILD_ARGS workdir/recipe" export CONDA_OUT="$(conda render --output $CONDA_BUILD_ARGS | grep conda-bld | grep tar.bz2 | tail -n 1 | sed -e's/-[0-9]\+\.tar/*.tar/' -e's/-git//')" - if [ "$TRAVIS_OS_NAME" = 'windows' ]; then + if [ "$OS_NAME" = 'windows' ]; then # conda render outputs Windows-style path which may contain wildcards; - # 'git bash' used by Travis works well with wildcards only in Unix-style paths export CONDA_OUT="$(cygpath -u $CONDA_OUT)" fi fi diff --git a/conda-env.sh b/conda-env.sh deleted file mode 100755 index 4bf59ab..0000000 --- a/conda-env.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/bash - -if ! which conda; then - export PATH=~/conda/bin:$PATH -fi - -# Disable this warning; -# xxxx/conda_build/environ.py:377: UserWarning: The environment variable -# 'TRAVIS' is being passed through with value 0. If you are splitting -# build and test phases with --no-test, please ensure that this value is -# also set similarly at test time. -export PYTHONWARNINGS=ignore::UserWarning:conda_build.environ - -if [ -z "$DATE_STR" ]; then - export DATE_NUM="$(date -u +%Y%m%d%H%M%S)" - export DATE_STR="$(date -u +%Y%m%d_%H%M%S)" - echo "Setting date number to $DATE_NUM" - echo "Setting date string to $DATE_STR" -fi -if [ -z "$GITREV" ]; then - export GITREV="$(git describe --long)" - echo "Setting git revision $GITREV" -fi - -export TRAVIS=0 -export CI=0 - -export TRAVIS_EVENT_TYPE="local" -echo "TRAVIS_EVENT_TYPE='${TRAVIS_EVENT_TYPE}'" - -export TRAVIS_BRANCH="$(git rev-parse --abbrev-ref HEAD)" -echo "TRAVIS_BRANCH='${TRAVIS_BRANCH}'" - -export TRAVIS_COMMIT="$(git rev-parse HEAD)" -echo "TRAVIS_COMMIT='${TRAVIS_COMMIT}'" - -export TRAVIS_REPO_SLUG="$(git rev-parse --abbrev-ref --symbolic-full-name @{u})" -echo "TRAVIS_REPO_SLUG='${TRAVIS_REPO_SLUG}'" - -./.travis/conda-meta-extra.sh -echo conda $@ -conda $@ diff --git a/conda-get.sh b/conda-get.sh index 16b5ed3..94f1652 100755 --- a/conda-get.sh +++ b/conda-get.sh @@ -4,7 +4,7 @@ set -x set -e CONDA_PATH=${1:-~/conda} -if [ $TRAVIS_OS_NAME = 'windows' ]; then +if [ $OS_NAME = 'windows' ]; then if [ ! -d $CONDA_PATH -o ! -z "$CI" ]; then choco install openssl.light choco install miniconda3 --params="/AddToPath:1" @@ -12,7 +12,7 @@ if [ $TRAVIS_OS_NAME = 'windows' ]; then export CONDA_PATH='/c/tools/miniconda3' export PATH=$CONDA_PATH/bin/:$CONDA_PATH/Scripts/:$PATH else - if [ $TRAVIS_OS_NAME = 'linux' ]; then + if [ $OS_NAME = 'linux' ]; then sys_name=Linux else sys_name=MacOSX diff --git a/conda-meta-extra.sh b/conda-meta-extra.sh deleted file mode 100755 index b729d18..0000000 --- a/conda-meta-extra.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/bash - -PACKAGE=${1:-PACKAGE} -if [ x$PACKAGE = x"" ]; then - echo "\$PACKAGE not set!" - exit 1 -fi - -rm -f $PACKAGE/recipe_append.yaml -cat > $PACKAGE/recipe_append.yaml < - - HDMI2USB Project - https://hdmi2usb.tv - travis: - job_id: $TRAVIS_JOB_ID - job_num: $TRAVIS_JOB_NUMBER - type: $TRAVIS_EVENT_TYPE - recipe: - repo: 'https://github.com/$TRAVIS_REPO_SLUG' - branch: $TRAVIS_BRANCH - commit: $TRAVIS_COMMIT - describe: $GITREV - date: $DATESTR -EOF -if [ ! -z "${TOOLCHAIN_ARCH}" ]; then - cat >> recipe_append.yaml <> $PACKAGE/recipe_append.yaml - cat $PACKAGE_CONDARC | sed -e's/^/ /' >> $PACKAGE/recipe_append.yaml -fi diff --git a/conda_build_config.yaml b/conda_build_config.yaml index 13aa574..46eb426 100644 --- a/conda_build_config.yaml +++ b/conda_build_config.yaml @@ -1,3 +1,3 @@ CONDA_BUILD_SYSROOT: - - /Users/travis/sdk/MacOSX10.9.sdk # [osx] + - /Users/runner/sdk/MacOSX10.9.sdk # [osx] diff --git a/download_sdk.sh b/download_sdk.sh index 74ee0f3..97f6d79 100755 --- a/download_sdk.sh +++ b/download_sdk.sh @@ -1,4 +1,4 @@ -if [ $TRAVIS_OS_NAME = 'osx' ]; then +if [ $OS_NAME = 'osx' ]; then if [[ ! -d $HOME/sdk/MacOSX10.9.sdk ]]; then git clone https://github.com/phracker/MacOSX-SDKs $HOME/sdk fi diff --git a/fixup-git.sh b/fixup-git.sh deleted file mode 100755 index f8423d1..0000000 --- a/fixup-git.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash - -source $TRAVIS_BUILD_DIR/.travis/common.sh -set -e - -# Git repo fixup -start_section "environment.git" "Setting up ${YELLOW}git checkout${NC}" -set -x -git fetch --unshallow || true -git fetch --tags -git submodule update --recursive --init -git submodule foreach git submodule update --recursive --init -$SPACER -git remote -v -git branch -v -git branch -D $TRAVIS_BRANCH -CURRENT_GITREV="$(git rev-parse HEAD)" -git checkout -b $TRAVIS_BRANCH $CURRENT_GITREV -git tag -l -git status -v -git describe --long -set +x -end_section "environment.git" diff --git a/install.sh b/install.sh index 4dc56e7..fe27db4 100755 --- a/install.sh +++ b/install.sh @@ -1,14 +1,14 @@ #!/bin/bash -source $TRAVIS_BUILD_DIR/.travis/common.sh +source $GITHUB_WORKSPACE/.github/scripts/common.sh set -e # Getting the conda environment start_section "environment.conda" "Setting up basic ${YELLOW}conda environment${NC}" -branch=${TRAVIS_PULL_REQUEST_BRANCH:-$TRAVIS_BRANCH} +branch="$(git rev-parse --abbrev-ref HEAD)" mkdir -p $BASE_PATH -./.travis/conda-get.sh $CONDA_PATH +$GITHUB_WORKSPACE/.github/scripts/conda-get.sh $CONDA_PATH hash -r if [ x$PACKAGE = x"" ]; then @@ -16,17 +16,17 @@ if [ x$PACKAGE = x"" ]; then exit 0 fi -# Add '.travis' build variants to the recipe dir (appended keys win in case of any conflict) -cat "$TRAVIS_BUILD_DIR/.travis/conda_build_config.yaml" >> "$PACKAGE/conda_build_config.yaml" +# Add build variants to the recipe dir (appended keys win in case of any conflict) +cat "$GITHUB_WORKSPACE/.github/scripts/conda_build_config.yaml" >> "$PACKAGE/conda_build_config.yaml" # Install conda-build-prepare python -m pip install git+https://github.com/litex-hub/conda-build-prepare@v0.1#egg=conda-build-prepare # The last channel will be on top of the environment's channel list -ADDITIONAL_CHANNELS="litex-hub $(echo $TRAVIS_REPO_SLUG | sed -e's@/.*$@@') litex-hub/label/travis-$branch-$TRAVIS_BUILD_ID $(echo $TRAVIS_REPO_SLUG | sed -e's@/.*$@@')/label/travis-$branch-$TRAVIS_BUILD_ID" +ADDITIONAL_CHANNELS="litex-hub $(echo $GITHUB_REPOSITORY | sed -e's@/.*$@@') litex-hub/label/ci-$branch-$GITHUB_RUN_ID $(echo $GITHUB_REPOSITORY | sed -e's@/.*$@@')/label/ci-$branch-$GITHUB_RUN_ID" ADDITIONAL_PACKAGES="conda-build=3.20.3 conda-verify jinja2 pexpect python=3.7" -if [[ "$TRAVIS_OS_NAME" != 'windows' ]]; then +if [[ "$OS_NAME" != 'windows' ]]; then ADDITIONAL_PACKAGES="$ADDITIONAL_PACKAGES ripgrep" fi @@ -34,7 +34,7 @@ fi python -m conda_build_prepare --channels $ADDITIONAL_CHANNELS --packages $ADDITIONAL_PACKAGES --dir workdir $PACKAGE # Freshly created conda environment will be activated by the common.sh -source $TRAVIS_BUILD_DIR/.travis/common.sh +source $GITHUB_WORKSPACE/.github/scripts/common.sh end_section "environment.conda" diff --git a/master-package.sh b/master-package.sh old mode 100644 new mode 100755 index 9a8d6cb..879e8f4 --- a/master-package.sh +++ b/master-package.sh @@ -1,11 +1,12 @@ #!/bin/bash +source $GITHUB_WORKSPACE/.github/scripts/common.sh # `for ... in $(anaconda ...` fails silently if there's any problem with anaconda -source $TRAVIS_BUILD_DIR/.travis/test_anaconda.sh +source $GITHUB_WORKSPACE/.github/scripts/test_anaconda.sh -branch=${TRAVIS_PULL_REQUEST_BRANCH:-$TRAVIS_BRANCH} +branch="$(git rev-parse --abbrev-ref HEAD)" # Move all packages from the current label to the main label -for package in $(anaconda -t $ANACONDA_TOKEN label --show travis-$branch-$TRAVIS_BUILD_ID 2>&1 | grep + | cut -f2 -d+) +for package in $(anaconda -t $ANACONDA_TOKEN label --show ci-$branch-$GITHUB_RUN_ID 2>&1 | grep + | cut -f2 -d+) do - anaconda -t $ANACONDA_TOKEN move --from-label travis-$branch-$TRAVIS_BUILD_ID --to-label main $package + anaconda -t $ANACONDA_TOKEN move --from-label ci-$branch-$GITHUB_RUN_ID --to-label main $package done diff --git a/script.sh b/script.sh index 8f8579c..49e4e2e 100755 --- a/script.sh +++ b/script.sh @@ -1,6 +1,6 @@ #!/bin/bash -source ./.travis/common.sh +source $GITHUB_WORKSPACE/.github/scripts/common.sh set -e $SPACER @@ -18,15 +18,15 @@ end_section "conda.check" $SPACER start_section "conda.build" "${GREEN}Building..${NC}" -if [[ $TRAVIS_OS_NAME != 'windows' ]]; then +if [[ $OS_NAME != 'windows' ]]; then if [[ $KEEP_ALIVE = 'true' ]]; then - travis_wait $TRAVIS_MAX_TIME python $TRAVIS_BUILD_DIR/.travis/.travis-output.py /tmp/output.log conda build $CONDA_BUILD_ARGS + ci_wait $CI_MAX_TIME python $GITHUB_WORKSPACE/.github/scripts/.ci-output.py /tmp/output.log conda build $CONDA_BUILD_ARGS else - python $TRAVIS_BUILD_DIR/.travis/.travis-output.py /tmp/output.log conda build $CONDA_BUILD_ARGS + python $GITHUB_WORKSPACE/.github/scripts/.ci-output.py /tmp/output.log conda build $CONDA_BUILD_ARGS fi else # Work-around: prevent console output being mangled - winpty.exe -Xallow-non-tty -Xplain conda build $CONDA_BUILD_ARGS 2>&1 | tee /tmp/output.log + conda build $CONDA_BUILD_ARGS | tee /tmp/output.log fi end_section "conda.build" diff --git a/test_anaconda.sh b/test_anaconda.sh index 5556038..4568711 100644 --- a/test_anaconda.sh +++ b/test_anaconda.sh @@ -3,18 +3,21 @@ echo if [ x$ANACONDA_TOKEN != x ]; then if ! anaconda -h &>/dev/null; then - echo 'WARNING: Missing `anaconda-client` package!' + echo 'ERROR: Missing `anaconda-client` package!' echo 'This Conda environment contains the following packages:' conda list + exit 1 else echo 'Testing ANACONDA_TOKEN with a simple `anaconda` call...' if anaconda -t $ANACONDA_TOKEN label --show main &>/dev/null; then echo 'ANACONDA_TOKEN works!' else - echo 'WARNING: Invalid ANACONDA_TOKEN!' + echo 'ERROR: Invalid ANACONDA_TOKEN!' + exit 1 fi fi else - echo 'WARNING: ANACONDA_TOKEN not set!' + echo 'ERROR: ANACONDA_TOKEN not set!' + exit 1 fi echo diff --git a/wait-for-statuses.py b/wait-for-statuses.py new file mode 100644 index 0000000..969bac0 --- /dev/null +++ b/wait-for-statuses.py @@ -0,0 +1,59 @@ +import urllib.request +import json +import subprocess +import time +import os +import sys + +# We're limited to this number by GH Actions API +# https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#list-jobs-for-a-workflow-run +max_jobs=100 + +status_url = "https://api.github.com/repos/" \ + + os.environ['GITHUB_REPOSITORY'] \ + + "/actions/runs/" \ + + os.environ['GITHUB_RUN_ID'] \ + + "/jobs" \ + + "?per_page=" + str(max_jobs) + +numOfJobs = int(os.environ['NUM_OF_JOBS']) + +if(numOfJobs > max_jobs): + sys.exit("ERROR: number of jobs exceeded max_jobs: " + str(max_jobs)) + + +while(True): + time.sleep(60) + countCompleted = 0 + + with urllib.request.urlopen(status_url) as url: + data = json.loads(url.read().decode()) + for j in data["jobs"]: + if(j["status"] == "completed"): + countCompleted += 1 + + print("Completed jobs: " + str(countCompleted) + ". Jobs overall: " + str(numOfJobs)) + if(countCompleted >= numOfJobs): + break + +# Check if all jobs succeeded +jobFailure = False +with urllib.request.urlopen(status_url) as url: + data = json.loads(url.read().decode()) + for j in data["jobs"]: + # THIS is master-package job, still in progress (not concluded) + if(j["conclusion"] != "success" and j["name"] != "master-package"): + jobFailure = True + break + +# Upload packages only when whole build succeeded +if(not jobFailure): + subprocess.call(os.path.join(os.environ['GITHUB_WORKSPACE'], + ".github/scripts/master-package.sh")) + +# Always clean up +subprocess.call(os.path.join(os.environ['GITHUB_WORKSPACE'], + ".github/scripts/cleanup-anaconda.sh")) + +if(jobFailure): + sys.exit("ERROR: some jobs failed")