Skip to content

Commit

Permalink
Testing: Update actions to use the GITHUB_OUTPUT env file; fixes ruci…
Browse files Browse the repository at this point in the history
  • Loading branch information
rdimaio committed Feb 21, 2024
1 parent 666faa5 commit 618229c
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 27 deletions.
4 changes: 2 additions & 2 deletions .github/actions/build-images-and-run-tests/action.yml
Expand Up @@ -26,11 +26,11 @@ runs:
else
i=$((i+1)); sleep 5;
echo "::warning::Building images failed, retrying…"
fi
fi
done
docker logout https://ghcr.io
if [[ -z "$IMAGES" ]]; then echo "::error::Building images failed ultimately"; exit 1; fi
echo "::set-output name=images::$IMAGES"
echo "images=$IMAGES" >> $GITHUB_OUTPUT
- name: Run test with cfg
shell: bash
run: 'echo ''{"matrix": ${{ inputs.cfg }}, "images": ${{ steps.images.outputs.images }} }'' | ./tools/test/run_tests.py'
16 changes: 8 additions & 8 deletions .github/workflows/autotest.yml
Expand Up @@ -128,15 +128,15 @@ jobs:
run: python3 -m pip install -U PyYAML
- name: Identify branch
id: branch
run: python3 -c 'from os import environ as env; print("::set-output name=branch::" + (env.get("GITHUB_BASE_REF", None) if env.get("GITHUB_BASE_REF", None) else env.get("GITHUB_REF", "master")))'
run: python3 -c 'from os import environ as env; from rucio.tools.github.workflow.util import set_output; set_output("branch", str((env.get("GITHUB_BASE_REF", None) if env.get("GITHUB_BASE_REF", None) else env.get("GITHUB_REF", "master"))))'
- name: Identify Matrix
id: matrix
run: |
EVENT="${{ github.event_name }}"
if [ $EVENT != 'schedule' ]; then
echo "::set-output name=matrix::$(./tools/test/matrix_parser.py < ./etc/docker/test/matrix.yml)"
echo "matrix=$(./tools/test/matrix_parser.py < ./etc/docker/test/matrix.yml)" >> $GITHUB_OUTPUT
else
echo "::set-output name=matrix::$(./tools/test/matrix_parser.py < ./etc/docker/test/matrix_nightly.yml)"
echo "matrix=$(./tools/test/matrix_parser.py < ./etc/docker/test/matrix_nightly.yml)" >> $GITHUB_OUTPUT
fi
outputs:
branch: ${{ steps.branch.outputs.branch }}
Expand Down Expand Up @@ -167,7 +167,7 @@ jobs:
done
docker logout https://ghcr.io
if [[ -z "$IMAGES" ]]; then echo "::error::Building images failed ultimately"; exit 1; fi
echo "::set-output name=images::$IMAGES"
echo "images=$IMAGES" >> $GITHUB_OUTPUT
- name: Run test with cfg
run: 'echo ''{"matrix": ${{ toJson(matrix.cfg) }}, "images": ${{ steps.images.outputs.images }} }'' | ./tools/test/run_tests.py'
release-patch-setup:
Expand All @@ -183,10 +183,10 @@ jobs:
run: python3 -m pip install -U sh PyYAML
- name: Grab latest release branch
id: grabrelease
run: echo "::set-output name=release_branch::$(echo "${{ github.event.repository.branches_url }}" | ./tools/github/workflow/grabrelease.py)"
run: echo "release_branch=$(echo "$(echo "${{ github.event.repository.branches_url }}" | ./tools/github/workflow/grabrelease.py)" >> $GITHUB_OUTPUT
- name: Fetch pull request commit range
id: prcommits
run: echo "::set-output name=source_commits::$(echo "${{ github.event.pull_request.commits_url }}" | ./tools/github/workflow/prcommits.py)"
run: echo "source_commits=$(echo "${{ github.event.pull_request.commits_url }}" | ./tools/github/workflow/prcommits.py)" >> $GITHUB_OUTPUT
- name: Test cherry-picking pull request changes
run: |
echo '{
Expand All @@ -198,7 +198,7 @@ jobs:
}' | ./tools/github/workflow/mergetest.py
- name: Identify Matrix
id: matrix
run: echo "::set-output name=matrix::$(./tools/test/matrix_parser.py < ./etc/docker/test/matrix.yml)"
run: echo "matrix=$(./tools/test/matrix_parser.py < ./etc/docker/test/matrix.yml)" >> $GITHUB_OUTPUT
outputs:
release_branch: ${{ steps.grabrelease.outputs.release_branch }}
source_commits: ${{ steps.prcommits.outputs.source_commits }}
Expand Down Expand Up @@ -242,6 +242,6 @@ jobs:
done
docker logout https://ghcr.io
if [[ -z "$IMAGES" ]]; then echo "::error::Building images failed ultimately"; exit 1; fi
echo "::set-output name=images::$IMAGES"
echo "images=$IMAGES" >> $GITHUB_OUTPUT
- name: Run test with cfg
run: 'echo ''{"matrix": ${{ toJson(matrix.cfg) }}, "images": ${{ steps.images.outputs.images }} }'' | ./tools/test/run_tests.py'
22 changes: 11 additions & 11 deletions .github/workflows/imagecache.yml
Expand Up @@ -16,7 +16,7 @@ jobs:
BRANCHES="$(echo "$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/branches{/branch}" | \
./tools/github/workflow/grabrelease.py --all --json --add master)"
echo "Will build image cache for branches: ${BRANCHES}"
echo "::set-output name=branches::${BRANCHES}"
echo "branches=${BRANCHES}" >> $GITHUB_OUTPUT
outputs:
branches: ${{ steps.branches.outputs.branches }}
build_autotests:
Expand All @@ -38,10 +38,10 @@ jobs:
MATRIX_PARSER_PY="${{ github.workspace }}/tools/test/matrix_parser.py"
MATRIX_CONF="${{ github.workspace }}/etc/docker/test/matrix.yml"
BUILD_IMAGES_PY="${{ github.workspace }}/tools/test/build_images.py"
echo "::set-output name=requirements_met::$(if [[ -r "$MATRIX_CONF" && -x "$MATRIX_PARSER_PY" && -x "$BUILD_IMAGES_PY" ]]; then echo "true"; else echo "false"; fi)"
echo "::set-output name=matrix_parser::$MATRIX_PARSER_PY"
echo "::set-output name=matrix_configuration::$MATRIX_CONF"
echo "::set-output name=build_images::$BUILD_IMAGES_PY"
echo "requirements_met=$(if [[ -r "$MATRIX_CONF" && -x "$MATRIX_PARSER_PY" && -x "$BUILD_IMAGES_PY" ]]; then echo "true"; else echo "false"; fi)" >> $GITHUB_OUTPUT
echo "matrix_parser=$MATRIX_PARSER_PY" >> $GITHUB_OUTPUT
echo "matrix_configuration=$MATRIX_CONF" >> $GITHUB_OUTPUT
echo "build_images=$BUILD_IMAGES_PY" >> $GITHUB_OUTPUT
- name: Update pip, install python requirements for matrix parser
if: ${{ steps.files.outputs.requirements_met == 'true' }}
run: |
Expand All @@ -50,7 +50,7 @@ jobs:
- name: Identify Matrix
if: ${{ steps.files.outputs.requirements_met == 'true' }}
id: matrix
run: echo "::set-output name=matrix::$(${{ steps.files.outputs.matrix_parser }} < ${{ steps.files.outputs.matrix_configuration }})"
run: echo "matrix=$(${{ steps.files.outputs.matrix_parser }} < ${{ steps.files.outputs.matrix_configuration }})" >> $GITHUB_OUTPUT
- name: Build and upload images
if: ${{ steps.files.outputs.requirements_met == 'true' }}
id: images
Expand Down Expand Up @@ -108,10 +108,10 @@ jobs:
MATRIX_PARSER_PY="${{ github.workspace }}/dev/rucio/tools/test/matrix_parser.py"
MATRIX_CONF="${{ github.workspace }}/dev/rucio/etc/docker/test/matrix_integration_tests.yml"
BUILD_IMAGES_PY="${{ github.workspace }}/dev/rucio/tools/test/build_images.py"
echo "::set-output name=requirements_met::$(if [[ -r "$MATRIX_CONF" && -x "$MATRIX_PARSER_PY" && -x "$BUILD_IMAGES_PY" ]]; then echo "true"; else echo "false"; fi)"
echo "::set-output name=matrix_parser::$MATRIX_PARSER_PY"
echo "::set-output name=matrix_configuration::$MATRIX_CONF"
echo "::set-output name=build_images::$BUILD_IMAGES_PY"
echo "requirements_met=$(if [[ -r "$MATRIX_CONF" && -x "$MATRIX_PARSER_PY" && -x "$BUILD_IMAGES_PY" ]]; then echo "true"; else echo "false"; fi)" >> $GITHUB_OUTPUT
echo "matrix_parser=$MATRIX_PARSER_PY" >> $GITHUB_OUTPUT
echo "matrix_configuration=$MATRIX_CONF" >> $GITHUB_OUTPUT
echo "build_images=$BUILD_IMAGES_PY" >> $GITHUB_OUTPUT
- name: Update pip, install python requirements for matrix parser
if: ${{ steps.files.outputs.requirements_met == 'true' }}
run: |
Expand All @@ -120,7 +120,7 @@ jobs:
- name: Identify Matrix
if: ${{ steps.files.outputs.requirements_met == 'true' }}
id: matrix
run: echo "::set-output name=matrix::$(${{ steps.files.outputs.matrix_parser }} < ${{ steps.files.outputs.matrix_configuration }})"
run: echo "matrix=$(${{ steps.files.outputs.matrix_parser }} < ${{ steps.files.outputs.matrix_configuration }})" >> $GITHUB_OUTPUT
- name: Build and upload images
if: ${{ steps.files.outputs.requirements_met == 'true' }}
id: images
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/integration_tests.yml
Expand Up @@ -15,10 +15,10 @@ jobs:
run: python3 -m pip install -U PyYAML
- name: Identify branch
id: branch
run: python3 -c 'from os import environ as env; print("::set-output name=branch::" + (env.get("GITHUB_BASE_REF", None) if env.get("GITHUB_BASE_REF", None) else env.get("GITHUB_REF", "master")))'
run: python3 -c 'from os import environ as env; from rucio.tools.github.workflow.util import set_output; set_output("branch", str((env.get("GITHUB_BASE_REF", None) if env.get("GITHUB_BASE_REF", None) else env.get("GITHUB_REF", "master"))))'
- name: Identify Matrix
id: matrix
run: echo "::set-output name=matrix::$(./tools/test/matrix_parser.py < ./etc/docker/test/matrix_integration_tests.yml)"
run: echo "matrix=$(./tools/test/matrix_parser.py < ./etc/docker/test/matrix_integration_tests.yml)" >> $GITHUB_OUTPUT
outputs:
branch: ${{ steps.branch.outputs.branch }}
matrix: ${{ steps.matrix.outputs.matrix }}
Expand Down Expand Up @@ -111,7 +111,7 @@ jobs:
done
docker logout https://ghcr.io
if [[ -z "$IMAGES" ]]; then echo "::error::Building images failed ultimately"; exit 1; fi
echo "::set-output name=images::$IMAGES"
echo "images=$IMAGES" >> $GITHUB_OUTPUT
- name: Prepare Docker Compose
shell: bash
run: |
Expand Down Expand Up @@ -149,7 +149,7 @@ jobs:
run: |
docker exec -t dev_rucio_1 tools/pytest.sh -v --tb=short --export-artifacts-from="test_tpc" tests/test_tpc.py
FTS_LOG_FILE=$(docker exec -t dev_rucio_1 cat /tmp/test_tpc.artifact)
echo "::set-output name=fts3log::$FTS_LOG_FILE"
echo "fts3log=$FTS_LOG_FILE" >> $GITHUB_OUTPUT
- name: Verify TPC transfers from FTS logs
shell: bash
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/vo_tests.yml
Expand Up @@ -16,10 +16,10 @@ jobs:
run: python3 -m pip install -U PyYAML
- name: Identify branch
id: branch
run: python3 -c 'from os import environ as env; print("::set-output name=branch::" + (env.get("GITHUB_BASE_REF", None) if env.get("GITHUB_BASE_REF", None) else env.get("GITHUB_REF", "master")))'
run: python3 -c 'from os import environ as env; from rucio.tools.github.workflow.util import set_output; set_output("branch", str((env.get("GITHUB_BASE_REF", None) if env.get("GITHUB_BASE_REF", None) else env.get("GITHUB_REF", "master"))))'
- name: Identify Matrix
id: matrix
run: echo "::set-output name=matrix::$(./tools/test/votest_helper.py)"
run: echo "matrix=$(./tools/test/votest_helper.py)" >> $GITHUB_OUTPUT
outputs:
branch: ${{ steps.branch.outputs.branch }}
matrix: ${{ steps.matrix.outputs.matrix }}
Expand Down
5 changes: 5 additions & 0 deletions tools/github/workflow/util.py
Expand Up @@ -15,6 +15,7 @@
# limitations under the License.

import json
import os
import sys
import urllib.request

Expand Down Expand Up @@ -43,3 +44,7 @@ def all_branches(branches_url: str):
branches = map(lambda b: b["name"], branches)
branches_url = get_next_link(answer)
yield from branches

def set_output(name: str, value: str):
with open(os.environ['GITHUB_OUTPUT'], 'a') as fh:
print(f'{name}={value}', file=fh)

0 comments on commit 618229c

Please sign in to comment.