diff --git a/.github/workflows/autotest.yml b/.github/workflows/autotest.yml index 4713726810..41495f1616 100644 --- a/.github/workflows/autotest.yml +++ b/.github/workflows/autotest.yml @@ -170,78 +170,3 @@ jobs: 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: - if: | - github.event_name == 'pull_request' && !startsWith(github.event.pull_request.base.ref, 'release') && !startsWith(github.event.pull_request.head.ref, 'feature') - && (github.repository_owner == 'rucio' || github.event_name != 'schedule') - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Update pip - run: python3 -m pip install -U pip setuptools - - name: Install python requirements for matrix_parser.py - run: python3 -m pip install -U sh PyYAML - - name: Grab latest release branch - id: grabrelease - 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 "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 '{ - "source_remote_name": "${{ github.actor }}", - "source_remote": "${{ github.event.pull_request.head.repo.full_name }}", - "source_commits": "${{ steps.prcommits.outputs.source_commits }}", - "target_remote": "${{ github.event.pull_request.base.repo.full_name }}", - "target_branch": "${{ steps.grabrelease.outputs.release_branch }}" - }' | ./tools/github/workflow/mergetest.py - - name: Identify Matrix - id: matrix - 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 }} - matrix: ${{ steps.matrix.outputs.matrix }} - release-patch-test: - needs: release-patch-setup - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - cfg: ${{ fromJson(needs.release-patch-setup.outputs.matrix) }} - steps: - - uses: actions/checkout@v4 - - name: Update pip - run: python3 -m pip install -U pip setuptools - - name: Install python requirements for mergetest.py - run: python3 -m pip install -U sh - - name: Cherry-pick pull request changes - run: | - echo '{ - "source_remote_name": "${{ github.actor }}", - "source_remote": "${{ github.event.pull_request.head.repo.full_name }}", - "source_commits": "${{ needs.release-patch-setup.outputs.source_commits }}", - "target_remote": "${{ github.event.pull_request.base.repo.full_name }}", - "target_branch": "${{ needs.release-patch-setup.outputs.release_branch }}" - }' | ./tools/github/workflow/mergetest.py - - name: Build images - id: images - shell: bash - run: | - docker login https://ghcr.io -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }} - i=0; until [ "$i" -ge 3 ]; do - IMAGES=$(echo '${{ toJson(matrix.cfg) }}' | DOCKER_BUILDKIT=1 ./tools/test/build_images.py \ - --cache-repo ghcr.io/${{ github.repository }} \ - --branch "${{ needs.release-patch-setup.outputs.release_branch }}" ./etc/docker/test || echo "") - if [[ -n $IMAGES ]]; then break; - else - i=$((i+1)); sleep 5; - echo "::warning::Building images failed, retrying…" - fi - done - docker logout https://ghcr.io - if [[ -z "$IMAGES" ]]; then echo "::error::Building images failed ultimately"; exit 1; fi - 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' diff --git a/tools/github/workflow/mergetest.py b/tools/github/workflow/mergetest.py deleted file mode 100755 index 58d284b691..0000000000 --- a/tools/github/workflow/mergetest.py +++ /dev/null @@ -1,83 +0,0 @@ -#!/usr/bin/env python3 -# -*- 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. - -import json -import os -import pathlib -import sys - -import sh -from sh import git - - -def get_github_url(): - return os.environ.get('GITHUB_URL', default='https://github.com') - - -def add_or_set_git_remote(remote_name, remote_uri): - if remote_name in str(git.remote()).splitlines(keepends=False): - git.remote("set-url", remote_name, remote_uri) - else: - git.remote.add(remote_name, remote_uri) - - -def set_git_author_info(name: str, email: str): - git.config("user.name", name) - git.config("user.email", email) - - -def main(): - options = json.load(sys.stdin) - - github_remote_url = f"{get_github_url()}/{options['target_remote']}.git" - if len(list(pathlib.Path('.').iterdir())) > 0: - print("Found existing files in work directory", file=sys.stderr) - assert pathlib.Path('.git').exists(), "if files are present in the work dir, it must be a git work tree" - remote = "origin" - if options["source_remote_name"] == remote: - remote = remote + "2" - add_or_set_git_remote(remote, github_remote_url) - print(f"Fetching from {github_remote_url}", file=sys.stderr) - git.fetch(remote) - print(f"Checking out {options['target_branch']} from {remote}/{options['target_branch']}", file=sys.stderr) - git.checkout("-B", options['target_branch'], f"{remote}/{options['target_branch']}") - print(f"Cleaning work tree", file=sys.stderr) - git.reset("--hard", "HEAD") - git.clean("-fdx") - else: - print(f"Cloning {options['target_branch']} from {github_remote_url}", file=sys.stderr) - git.clone("--branch", options['target_branch'], github_remote_url, ".") - - if options['target_remote'] != options['source_remote']: - source_remote_name = options['source_remote_name'] - add_or_set_git_remote(source_remote_name, f"{get_github_url()}/{options['source_remote']}.git") - print(f"Fetching from {get_github_url()}/{options['source_remote']}.git", file=sys.stderr) - git.fetch(source_remote_name) - - set_git_author_info(f"GitHub Action {os.environ['GITHUB_ACTION']}", "action@localhost") - - try: - git("cherry-pick", options['source_commits']) - print(f"Source commits ({options['source_commits']}) were successfully cherry-picked " - f"onto {options['target_remote']}:{options['target_branch']}", file=sys.stderr) - except sh.ErrorReturnCode: - print(f"Source commits ({options['source_commits']}) could not be cherry-picked " - f"onto {options['target_remote']}:{options['target_branch']}", file=sys.stderr) - raise - - -if __name__ == "__main__": - main() diff --git a/tools/github/workflow/prcommits.py b/tools/github/workflow/prcommits.py deleted file mode 100755 index ab659bfd09..0000000000 --- a/tools/github/workflow/prcommits.py +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/env python3 -# -*- 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. - -import json -import sys -import urllib.request - -from util import req_json, get_next_link - - -def main(): - commits_url = sys.stdin.read().strip() - - def allcommits(): - next_link = commits_url - while next_link: - with urllib.request.urlopen(req_json(next_link)) as answer: - commits = json.load(answer) - shalist = map(lambda c: c["sha"], commits) - next_link = get_next_link(answer) - yield from shalist - - commit_list = list(allcommits()) - print(f"{commit_list[0]}^..{commit_list[-1]}") - - -if __name__ == "__main__": - main()