You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
164 lines
6.2 KiB
164 lines
6.2 KiB
10 months ago
|
name: reuse-copr-build@TF
|
||
|
|
||
|
on:
|
||
|
workflow_call:
|
||
|
secrets:
|
||
|
FEDORA_COPR_LOGIN:
|
||
|
required: true
|
||
|
FEDORA_COPR_TOKEN:
|
||
|
required: true
|
||
|
outputs:
|
||
|
artifacts:
|
||
|
description: "A string with test artifacts to install in tft test env"
|
||
|
value: ${{ jobs.reusable_workflow_copr_build_job.outputs.artifacts }}
|
||
|
|
||
|
jobs:
|
||
|
reusable_workflow_copr_build_job:
|
||
|
# This job only runs for '/rerun' pull request comments by owner, member, or collaborator of the repo/organization.
|
||
|
name: Build copr builds for tft tests
|
||
|
runs-on: ubuntu-20.04
|
||
|
outputs:
|
||
|
artifacts: ${{ steps.gen_artifacts.outputs.artifacts }}
|
||
|
if: |
|
||
|
github.event.issue.pull_request
|
||
|
&& startsWith(github.event.comment.body, '/rerun')
|
||
|
&& contains(fromJson('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.comment.author_association)
|
||
|
steps:
|
||
|
- name: Update repository
|
||
|
id: repo_update
|
||
|
run: sudo apt-get update
|
||
|
|
||
|
- name: Install necessary deps
|
||
|
id: deps_install
|
||
|
run: sudo apt-get install -y libkrb5-dev
|
||
|
|
||
|
- name: Get pull request number
|
||
|
id: pr_nr
|
||
|
run: |
|
||
|
PR_URL="${{ github.event.comment.issue_url }}"
|
||
|
echo "::set-output name=pr_nr::${PR_URL##*/}"
|
||
|
|
||
|
- name: Checkout
|
||
|
# TODO: The correct way to checkout would be to use similar approach as in get_commit_by_timestamp function of
|
||
|
# the github gluetool module (i.e. do not use HEAD but the last commit before comment).
|
||
|
id: checkout
|
||
|
uses: actions/checkout@v2
|
||
|
with:
|
||
|
ref: "refs/pull/${{ steps.pr_nr.outputs.pr_nr }}/head"
|
||
|
|
||
|
- name: Get ref and sha
|
||
|
id: ref_sha
|
||
|
run: |
|
||
|
echo "::set-output name=sha::$(git rev-parse --short HEAD)"
|
||
|
echo "::set-output name=ref::refs/pull/${{ steps.pr_nr.outputs.pr_nr }}/head"
|
||
|
|
||
|
- name: Trigger copr build
|
||
|
id: copr_build
|
||
|
env:
|
||
|
COPR_CONFIG: "copr_fedora.conf"
|
||
|
COPR_CHROOT: "epel-7-x86_64,epel-8-x86_64"
|
||
|
COPR_REPO: "@oamg/leapp"
|
||
|
run: |
|
||
|
cat << EOF > $COPR_CONFIG
|
||
|
[copr-cli]
|
||
|
login = ${{ secrets.FEDORA_COPR_LOGIN }}
|
||
|
username = oamgbot
|
||
|
token = ${{ secrets.FEDORA_COPR_TOKEN }}
|
||
|
copr_url = https://copr.fedorainfracloud.org
|
||
|
# expiration date: 2030-07-04
|
||
|
EOF
|
||
|
|
||
|
pip install copr-cli
|
||
|
PR=${{ steps.pr_nr.outputs.pr_nr }} COPR_CONFIG=$COPR_CONFIG COPR_REPO="$COPR_REPO" COPR_CHROOT=$COPR_CHROOT make copr_build | tee copr.log
|
||
|
|
||
|
COPR_URL=$(grep -Po 'https://copr.fedorainfracloud.org/coprs/build/\d+' copr.log)
|
||
|
echo "::set-output name=copr_url::${COPR_URL}"
|
||
|
echo "::set-output name=copr_id::${COPR_URL##*/}"
|
||
|
|
||
|
- name: Add comment with copr build url
|
||
|
# TODO: Create comment when copr build fails.
|
||
|
id: link_copr
|
||
|
uses: actions/github-script@v4
|
||
|
with:
|
||
|
script: |
|
||
|
github.issues.createComment({
|
||
|
issue_number: context.issue.number,
|
||
|
owner: context.repo.owner,
|
||
|
repo: context.repo.repo,
|
||
|
body: 'Copr build succeeded: ${{ steps.copr_build.outputs.copr_url }}'
|
||
|
})
|
||
|
|
||
|
- name: Get dependent leapp pr number from rerun comment
|
||
|
uses: actions-ecosystem/action-regex-match@v2
|
||
|
id: leapp_pr_regex_match
|
||
|
with:
|
||
|
text: ${{ github.event.comment.body }}
|
||
|
regex: '^/(rerun|rerun-sst)\s+([0-9]+)\s*$'
|
||
|
|
||
|
- name: If leapp_pr was specified in the comment - trigger copr build
|
||
|
# TODO: XXX FIXME This should schedule copr build for leapp but for now it will be just setting an env var
|
||
|
id: leapp_pr
|
||
|
if: ${{ steps.leapp_pr_regex_match.outputs.match != '' }}
|
||
|
run: |
|
||
|
echo "::set-output name=leapp_pr::${{ steps.leapp_pr_regex_match.outputs.group2 }}"
|
||
|
|
||
|
- name: Checkout leapp
|
||
|
id: checkout_leapp
|
||
|
if: ${{ steps.leapp_pr_regex_match.outputs.match != '' }}
|
||
|
uses: actions/checkout@v2
|
||
|
with:
|
||
|
repository: "oamg/leapp"
|
||
|
ref: "refs/pull/${{ steps.leapp_pr.outputs.leapp_pr }}/head"
|
||
|
|
||
|
- name: Get ref and sha for leapp
|
||
|
id: ref_sha_leapp
|
||
|
if: ${{ steps.leapp_pr_regex_match.outputs.match != '' }}
|
||
|
run: |
|
||
|
echo "::set-output name=sha::$(git rev-parse --short HEAD)"
|
||
|
echo "::set-output name=ref::refs/pull/${{ steps.leapp_pr.outputs.leapp_pr }}/head"
|
||
|
|
||
|
- name: Trigger copr build for leapp
|
||
|
id: copr_build_leapp
|
||
|
if: ${{ steps.leapp_pr_regex_match.outputs.match != '' }}
|
||
|
env:
|
||
|
COPR_CONFIG: "copr_fedora.conf"
|
||
|
COPR_CHROOT: "epel-7-x86_64,epel-8-x86_64"
|
||
|
COPR_REPO: "@oamg/leapp"
|
||
|
run: |
|
||
|
cat << EOF > $COPR_CONFIG
|
||
|
[copr-cli]
|
||
|
login = ${{ secrets.FEDORA_COPR_LOGIN }}
|
||
|
username = oamgbot
|
||
|
token = ${{ secrets.FEDORA_COPR_TOKEN }}
|
||
|
copr_url = https://copr.fedorainfracloud.org
|
||
|
# expiration date: 2030-07-04
|
||
|
EOF
|
||
|
|
||
|
pip install copr-cli
|
||
|
PR=${{ steps.leapp_pr.outputs.leapp_pr }} COPR_CONFIG=$COPR_CONFIG COPR_REPO="$COPR_REPO" COPR_CHROOT=$COPR_CHROOT make copr_build | tee copr.log
|
||
|
|
||
|
COPR_URL=$(grep -Po 'https://copr.fedorainfracloud.org/coprs/build/\d+' copr.log)
|
||
|
echo "::set-output name=copr_url::${COPR_URL}"
|
||
|
echo "::set-output name=copr_id::${COPR_URL##*/}"
|
||
|
|
||
|
- name: Add comment with copr build url for leapp
|
||
|
# TODO: Create comment when copr build fails.
|
||
|
id: link_copr_leapp
|
||
|
if: ${{ steps.leapp_pr_regex_match.outputs.match != '' }}
|
||
|
uses: actions/github-script@v4
|
||
|
with:
|
||
|
script: |
|
||
|
github.issues.createComment({
|
||
|
issue_number: context.issue.number,
|
||
|
owner: context.repo.owner,
|
||
|
repo: context.repo.repo,
|
||
|
body: 'Copr build succeeded: ${{ steps.copr_build_leapp.outputs.copr_url }}'
|
||
|
})
|
||
|
|
||
|
- name: Generate artifacts output
|
||
|
id: gen_artifacts
|
||
|
env:
|
||
|
ARTIFACTS: ${{ steps.leapp_pr_regex_match.outputs.match != '' && format('{0};{1}', steps.copr_build_leapp.outputs.copr_id, steps.copr_build.outputs.copr_id) || steps.copr_build.outputs.copr_id }}
|
||
|
run: |
|
||
|
echo "::set-output name=artifacts::${{ env.ARTIFACTS }}"
|