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 authored and bari12 committed Mar 4, 2024
1 parent 2c5b291 commit ca273f1
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .github/actions/build-images-and-run-tests/action.yml
Expand Up @@ -30,7 +30,7 @@ runs:
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 tools/github/workflow/set_branch_output_env.py
- 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 "${{ 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 tools/github/workflow/set_branch_output_env.py
- 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 tools/github/workflow/set_branch_output_env.py
- 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
29 changes: 29 additions & 0 deletions tools/github/workflow/set_branch_output_env.py
@@ -0,0 +1,29 @@
# -*- coding: utf-8 -*-
# Copyright European Organization for Nuclear Research (CERN) since 2012
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from os import environ as env


def set_output(name: str, value: str) -> None:
with open(env['GITHUB_OUTPUT'], 'a') as fh:
print(f'{name}={value}', file=fh)


def main():
set_output("branch", str((env.get("GITHUB_BASE_REF", None) if env.get("GITHUB_BASE_REF", None) else env.get("GITHUB_REF", "master"))))


if __name__ == "__main__":
main()

0 comments on commit ca273f1

Please sign in to comment.