skip step output #130
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: Build workflow-testing | |
on: | |
push: | |
branches: | |
- "**" | |
tags: | |
- 'v[0-9]+.[0-9]+.[0-9]+' | |
pull_request: | |
workflow_dispatch: | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
trigger: | |
# store trigger reason | |
runs-on: ubuntu-latest | |
outputs: | |
is_release: ${{ steps.reason.outputs.is_release }} | |
is_push_on_default_branch: ${{ steps.reason.outputs.is_push_on_default_branch }} | |
steps: | |
- id: reason | |
run: | | |
echo "is_release=${{ startsWith(github.ref, 'refs/tags/v') }}" >> $GITHUB_OUTPUT | |
echo "is_push_on_default_branch=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}" >> $GITHUB_OUTPUT | |
only-on-master: | |
needs: [trigger] | |
runs-on: ubuntu-latest | |
if: needs.trigger.outputs.is_push_on_default_branch == 'true' | |
outputs: | |
notebooks-branch: ${{ steps.write-output.outputs.notebooks_branch }} | |
steps: | |
- id: write-output | |
run: | | |
echo "yo" | |
echo "notebooks_branch=toto" >> $GITHUB_OUTPUT | |
on-all-branches: | |
needs: only-on-master | |
runs-on: ubuntu-latest | |
if: always() | |
steps: | |
- run: echo yo ${{ needs.only-on-master.outputs.notebooks-branch }} | |
testing-file-existence: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
minizinc_prerequisites_cmdline: [""] | |
steps: | |
- name: prerequisites | |
run: | | |
${{ matrix.minizinc_prerequisites_cmdline }} | |
- name: Check if coverage report exists | |
id: check-cov | |
run: | | |
if [ -f coverage.xml ]; then | |
coverage_exists=true | |
else | |
coverage_exists=false | |
fi | |
echo ${coverage_exists} | |
echo "coverage_exists=${coverage_exists}" >> $GITHUB_OUTPUT | |
- name: test output previous step | |
run: | | |
echo ${{ steps.check-cov.outputs.coverage_exists }} | |
echo ${{ steps.check-cov.outputs.coverage_exists == 'true' }} | |
- name: Export coverage report (if existing) | |
if: steps.check-coverage-report.ouputs.coverage_exists == 'true' | |
run: echo "exporting" | |
- name: Check if coverage report exists II | |
id: check-coverage-report | |
run: | | |
touch coverage.xml | |
if [ -f coverage.xml ]; then | |
coverage_exists=true | |
else | |
coverage_exists=false | |
fi | |
echo ${coverage_exists} | |
echo "coverage_exists=${coverage_exists}" >> $GITHUB_OUTPUT | |
- name: test output previous step | |
run: | | |
echo ${{ steps.check-coverage-report.outputs.coverage_exists }} | |
echo ${{ steps.check-coverage-report.outputs.coverage_exists == 'true' }} | |
- name: Export coverage report (if existing) II | |
if: steps.check-coverage-report.outputs.coverage_exists == 'true' | |
run: echo "exporting" | |
pwd: | |
runs-on: ubuntu-latest | |
steps: | |
- run: | | |
pwd | |
echo $HOME | |
build: | |
runs-on: ubuntu-latest | |
needs: [trigger] | |
outputs: | |
do_version: ${{ steps.get_wheel_version.outputs.version }} | |
steps: | |
- name: get wheel version and save it | |
id: get_wheel_version | |
run: | | |
if ${{ needs.trigger.outputs.is_release }}; then | |
version=${GITHUB_REF/refs\/tags\/v/} # stripping "refs/tags/v" | |
else | |
version="0.0.0" | |
fi | |
echo "version=$version" | |
echo "version=$version" >> $GITHUB_OUTPUT | |
deploy-master-doc: | |
# for default branch | |
needs: [trigger] | |
if: needs.trigger.outputs.is_push_on_default_branch == 'true' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Deploy documentation in a version subfolder on GH pages | |
uses: JamesIves/github-pages-deploy-action@v4 | |
with: | |
branch: gh-pages # The branch the action should deploy to. | |
folder: docs # The folder the action should deploy. | |
target-folder: /${{ github.event.repository.default_branch }} # The folder the action should deploy to. | |
commit-message: publish documentation for ${{ github.event.repository.default_branch }} | |
single-commit: true | |
deploy-release-doc: | |
# for release tags | |
needs: [trigger, build] | |
if: needs.trigger.outputs.is_release == 'true' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Deploy documentation in a version subfolder on GH pages | |
uses: JamesIves/github-pages-deploy-action@v4 | |
with: | |
branch: gh-pages # The branch the action should deploy to. | |
folder: docs # The folder the action should deploy. | |
target-folder: /${{ needs.build.outputs.do_version }} # The folder the action should deploy to. | |
commit-message: publish documentation for ${{ needs.build.outputs.do_version }} | |
single-commit: true | |
create-binder-env: | |
runs-on: ubuntu-latest | |
needs: [trigger, build] | |
env: | |
BINDER_ENV_REF: binder # default reference: binder branch | |
outputs: | |
binder_env_ref: ${{ steps.get_binder_env_ref.outputs.binder_env_ref }} | |
steps: | |
- name: Checkout binder branch | |
if: | | |
(needs.trigger.outputs.is_push_on_default_branch == 'true') | |
|| (needs.trigger.outputs.is_release == 'true') | |
uses: actions/checkout@v3 | |
with: | |
ref: binder | |
- name: Update environment.yml | |
if: | | |
(needs.trigger.outputs.is_push_on_default_branch == 'true') | |
|| (needs.trigger.outputs.is_release == 'true') | |
run: | | |
if ${{ needs.trigger.outputs.is_release == 'true' }}; then | |
# RELEASE MODE | |
# Specify the proper discrete-optimization version | |
sed_replacement_pattern="\1- discrete-optimization==${{ needs.build.outputs.do_version }}" | |
if ${{ github.repository != 'airbus/discrete-optimization' && secrets.TEST_PYPI_API_TOKEN != '' }} == 'true'; then | |
# release to be deployed on TestPyPI | |
sed_replacement_pattern="${sed_replacement_pattern}\n\1- --extra-index-url https://test.pypi.org/simple/" | |
fi | |
sed_command="s|\(\s*\)-.*egg=discrete-optimization$|${sed_replacement_pattern}|" | |
echo $sed_command | |
sed -i -e "$sed_command" environment.yml | |
cat environment.yml | |
# Commit new environment | |
git config user.name "Actions" | |
git config user.email "[email protected]" | |
git commit environment.yml -m "Specify binder environment for release ${{ needs.build.outputs.do_version }}" | |
# Get sha1 to be used by binder for the environment, update the binder env reference | |
echo "BINDER_ENV_REF=$(git rev-parse --verify HEAD)" >> $GITHUB_ENV | |
# Revert for the default branch binder env | |
git revert HEAD -n | |
git commit -m "Revert to binder environment for master branch" | |
else | |
# DEFAULT BRANCH MODE | |
# Specify the proper discrete-optimization version (current master sha1) | |
pip_spec="git+${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}@${GITHUB_SHA}#egg=discrete-optimization" | |
echo $pip_spec | |
sed -i -e "s|\(\s*\)-.*egg=discrete-optimization$|\1- ${pip_spec}|" environment.yml | |
cat environment.yml | |
# Commit new environment | |
git config user.name "Actions" | |
git config user.email "[email protected]" | |
git commit environment.yml -m "Update binder environment for default branch" | |
fi | |
# Push binder branch with the updated environment | |
git push origin binder | |
- name: Checkout triggering branch to get the script pre-building the binder env | |
if: | | |
(needs.trigger.outputs.is_push_on_default_branch == 'true') | |
|| (needs.trigger.outputs.is_release == 'true') | |
uses: actions/checkout@v3 | |
- name: Trigger a build on each BinderHub deployments in the mybinder.org federation | |
if: | | |
(needs.trigger.outputs.is_push_on_default_branch == 'true') | |
|| (needs.trigger.outputs.is_release == 'true') | |
run: | | |
echo Triggering binder environment build for ${GITHUB_REPOSITORY}/${BINDER_ENV_REF} | |
bash scripts/trigger_binder.sh https://gke.mybinder.org/build/gh/${GITHUB_REPOSITORY}/${BINDER_ENV_REF} | |
bash scripts/trigger_binder.sh https://ovh.mybinder.org/build/gh/${GITHUB_REPOSITORY}/${BINDER_ENV_REF} | |
bash scripts/trigger_binder.sh https://turing.mybinder.org/build/gh/${GITHUB_REPOSITORY}/${BINDER_ENV_REF} | |
bash scripts/trigger_binder.sh https://gesis.mybinder.org/build/gh/${GITHUB_REPOSITORY}/${BINDER_ENV_REF} | |
- name: Store binder env reference | |
id: get_binder_env_ref | |
run: | | |
echo "binder_env_ref=$BINDER_ENV_REF" | |
echo "binder_env_ref=$BINDER_ENV_REF" >> $GITHUB_OUTPUT | |
build-doc: | |
runs-on: ubuntu-latest | |
needs: create-binder-env | |
steps: | |
- name: Set env variables for github+binder links in doc | |
run: | | |
# binder environment repo and branch | |
AUTODOC_BINDER_ENV_GH_REPO_NAME="${GITHUB_REPOSITORY}" | |
AUTODOC_BINDER_ENV_GH_BRANCH="${{ needs.create-binder-env.outputs.binder_env_ref }}" | |
# notebooks source repo and branch depending if it is a commit push or a PR | |
if [[ $GITHUB_REF == refs/pull* ]]; | |
then | |
AUTODOC_NOTEBOOKS_REPO_URL="${GITHUB_SERVER_URL}/${{ github.event.pull_request.head.repo.full_name }}" | |
AUTODOC_NOTEBOOKS_BRANCH=${GITHUB_HEAD_REF} | |
elif [[ $GITHUB_REF == refs/heads* ]]; | |
then | |
AUTODOC_NOTEBOOKS_REPO_URL=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY} | |
AUTODOC_NOTEBOOKS_BRANCH=${GITHUB_REF/refs\/heads\//} | |
fi | |
# export in GITHUB_ENV for next steps | |
echo "AUTODOC_BINDER_ENV_GH_REPO_NAME=${AUTODOC_BINDER_ENV_GH_REPO_NAME}" >> $GITHUB_ENV | |
echo "AUTODOC_BINDER_ENV_GH_BRANCH=${AUTODOC_BINDER_ENV_GH_BRANCH}" >> $GITHUB_ENV | |
echo "AUTODOC_NOTEBOOKS_REPO_URL=${AUTODOC_NOTEBOOKS_REPO_URL}" >> $GITHUB_ENV | |
echo "AUTODOC_NOTEBOOKS_BRANCH=${AUTODOC_NOTEBOOKS_BRANCH}" >> $GITHUB_ENV | |
# check computed variables | |
echo "Binder env: ${AUTODOC_BINDER_ENV_GH_REPO_NAME}/${AUTODOC_BINDER_ENV_GH_BRANCH}" | |
echo "Notebooks source: ${AUTODOC_NOTEBOOKS_REPO_URL}/tree/${AUTODOC_NOTEBOOKS_BRANCH}" | |
job_see_trigger: | |
runs-on: ubuntu-latest | |
needs: trigger | |
steps: | |
- run: | | |
echo ${{ needs.trigger.outputs.is_release }} | |
echo ${{ needs.trigger.outputs.is_push_on_default_branch }} | |
if ${{ needs.trigger.outputs.is_release }}; then echo this is a release; fi | |
if ${{ needs.trigger.outputs.is_push_on_default_branch }}; then echo this is a push on default branch; fi | |
job_only_release: | |
runs-on: ubuntu-latest | |
needs: trigger | |
if: needs.trigger.outputs.is_release == 'true' | |
steps: | |
- run: | | |
echo this is a release | |
job_only_default_branch: | |
runs-on: ubuntu-latest | |
needs: trigger | |
if: needs.trigger.outputs.is_push_on_default_branch == 'true' | |
steps: | |
- run: | | |
echo this is a push on default branch | |
job_only_default_branch_or_release: | |
runs-on: ubuntu-latest | |
needs: trigger | |
if: | | |
(needs.trigger.outputs.is_push_on_default_branch == 'true') | |
|| (needs.trigger.outputs.is_release == 'true') | |
steps: | |
- run: | | |
if ${{ needs.trigger.outputs.is_release }}; then echo this is a release; fi | |
if ${{ needs.trigger.outputs.is_push_on_default_branch }}; then echo this is a push on default branch; fi | |
job0: | |
if: true | |
runs-on: ubuntu-latest | |
steps: | |
- run: echo called | |
job1: | |
if: false | |
needs: job0 | |
runs-on: ubuntu-latest | |
steps: | |
- run: echo never called | |
job2: | |
if: true | |
runs-on: ubuntu-latest | |
steps: | |
- run: echo never called | |
job12: | |
needs: [job1, job2] | |
if: | | |
always() | |
&& ( | |
(needs.job1.result == 'success') | |
|| (needs.job2.result == 'success') | |
) | |
runs-on: ubuntu-latest | |
steps: | |
- run: | | |
echo ${{ needs.job1.result }} | |
echo ${{ needs.job2.result }} | |
echo ${{ contains(needs.*.result, 'success') }} | |
job_for_tags_and_default: | |
runs-on: ubuntu-latest | |
if: startsWith(github.ref, 'refs/tags/v') || github.ref == format('refs/heads/{0}', github.event.repository.default_branch) | |
steps: | |
- name: Get doc version name | |
run: | | |
if [ ${GITHUB_REF} = refs/heads/${{ github.event.repository.default_branch }} ]; then | |
VERSION=${{ github.event.repository.default_branch }} | |
else | |
VERSION=${GITHUB_REF/refs\/tags\/v/} # stripping "refs/tags/v" | |
fi | |
echo "VERSION=$VERSION" >> $GITHUB_ENV | |
- name: test it | |
run: echo $VERSION | |
job_depending_on_skipped_test: | |
runs-on: ubuntu-latest | |
steps: | |
- run: echo should not run | |
job_only_on_default1: | |
runs-on: ubuntu-latest | |
if: $${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }} | |
steps: | |
- run: echo should work only on default | |
job_only_on_default2: | |
runs-on: ubuntu-latest | |
if: ${{ github.ref }} == refs/heads/${{ github.event.repository.default_branch }} | |
steps: | |
- run: echo should work only on default 2 | |
job_only_on_default3: | |
runs-on: ubuntu-latest | |
if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch) | |
steps: | |
- run: echo should work only on default | |
build2: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout source code | |
uses: actions/checkout@v2 | |
- name: Install build dependencies | |
run: pip install -U setuptools wheel | |
- name: Update version number according to pushed tag | |
if: startsWith(github.ref, 'refs/tags/v') | |
run: | | |
TAG_NAME=${GITHUB_REF/refs\/tags\//} # stripping "refs/tags/" | |
VERSION=${TAG_NAME/v/} # stripping "v" | |
echo $VERSION | |
# Replace in-place version number in package __init__.py, also used by setup.py | |
sed -i -e "s/^__version__\s*=.*$/__version__ = \"${VERSION}\"/g" workflow_testing/__init__.py | |
cat workflow_testing/__init__.py | |
- name: Build workflow_testing wheel | |
run: python setup.py bdist_wheel | |
- name: Upload as build artifacts | |
uses: actions/upload-artifact@v2 | |
with: | |
name: wheels | |
path: dist/*.whl | |
test: | |
runs-on: windows-2022 | |
needs: [build2] | |
defaults: | |
run: | |
shell: bash | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: "3.8" | |
- name: Download wheels artifact | |
uses: actions/[email protected] | |
with: | |
name: wheels | |
- name: install the library | |
run: | | |
python -m pip install wheels/workflow_testing*.whl | |
- run: | | |
chmod +x bin/hello | |
cd .. | |
minizinc_path=$(python -c "import workflow_testing, os; print(os.path.abspath(workflow_testing.__path__[0]))") | |
cd - | |
echo $minizinc_path | |
cygpath --unix $minizinc_path | |
minizinc_path=$(cygpath --unix $minizinc_path) | |
echo $minizinc_path | |
mv bin/hello $minizinc_path | |
ls $minizinc_path | |
export PATH=$minizinc_path:$PATH | |
echo $PATH | |
hello |