mirror of
https://github.com/flatcar/scripts.git
synced 2025-08-15 17:06:58 +02:00
Merge pull request #862 from flatcar/gabriel-samfira/add-on-pr-workflow
Add on pr workflow
This commit is contained in:
commit
1cfedaf8b3
10
.github/workflows/ci.yaml
vendored
10
.github/workflows/ci.yaml
vendored
@ -89,7 +89,7 @@ jobs:
|
|||||||
echo "arch=${arch}" >> $GITHUB_ENV
|
echo "arch=${arch}" >> $GITHUB_ENV
|
||||||
|
|
||||||
IMAGE_FORMATS="qemu_uefi"
|
IMAGE_FORMATS="qemu_uefi"
|
||||||
[ -z "${{ github.event.inputs.image_formats }}" ] || IMAGE_FORMATS="${{ github.event.inputs.image_formats }}"
|
[ -z "${{ inputs.image_formats }}" ] || IMAGE_FORMATS="${{ inputs.image_formats }}"
|
||||||
echo "IMAGE_FORMATS=${IMAGE_FORMATS}" >> $GITHUB_ENV
|
echo "IMAGE_FORMATS=${IMAGE_FORMATS}" >> $GITHUB_ENV
|
||||||
|
|
||||||
# Artifact root for images and torcx tarball as seen from within the container
|
# Artifact root for images and torcx tarball as seen from within the container
|
||||||
@ -101,8 +101,8 @@ jobs:
|
|||||||
# this with its IP address.
|
# this with its IP address.
|
||||||
echo "TORCX_TESTS_PACKAGE_URL=http://localhost:12345" >> $GITHUB_ENV
|
echo "TORCX_TESTS_PACKAGE_URL=http://localhost:12345" >> $GITHUB_ENV
|
||||||
|
|
||||||
if [ -n "${{ github.event.inputs.custom_sdk_version }}" ] ; then
|
if [ -n "${{ inputs.custom_sdk_version }}" ] ; then
|
||||||
echo "CUSTOM_SDK_VERSION=${{ github.event.inputs.custom_sdk_version }}" >> $GITHUB_ENV
|
echo "CUSTOM_SDK_VERSION=${{ inputs.custom_sdk_version }}" >> $GITHUB_ENV
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Build packages
|
- name: Build packages
|
||||||
@ -147,7 +147,7 @@ jobs:
|
|||||||
-cvf binpkgs.tar .
|
-cvf binpkgs.tar .
|
||||||
|
|
||||||
- name: Extract build logs
|
- name: Extract build logs
|
||||||
if: always()
|
if: always() && !cancelled()
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
@ -158,7 +158,7 @@ jobs:
|
|||||||
/build/${arch}-usr/var/tmp/portage
|
/build/${arch}-usr/var/tmp/portage
|
||||||
|
|
||||||
- name: Upload build logs
|
- name: Upload build logs
|
||||||
if: always()
|
if: always() && !cancelled()
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
retention-days: 7
|
retention-days: 7
|
||||||
|
@ -11,18 +11,18 @@ concurrency:
|
|||||||
cancel-in-progress: true
|
cancel-in-progress: true
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
check_maintainer_membership:
|
run_pre_checks:
|
||||||
# Only run if this is a PR comment that contains a valid command
|
# Only run if this is a PR comment that contains a valid command
|
||||||
if: |
|
if: ${{ github.event.issue.pull_request }} && ( contains(github.event.comment.body, '/build-image') || contains(github.event.comment.body, '/update-sdk'))
|
||||||
${{ github.event.issue.pull_request }} &&
|
|
||||||
( contains(github.event.comment.body, '/update-sdk') || contains(github.event.comment.body, '/build-image') )
|
|
||||||
name: Check if commenter is in the Flatcar maintainers team
|
name: Check if commenter is in the Flatcar maintainers team
|
||||||
outputs:
|
outputs:
|
||||||
maintainers: steps.step1.output.maintainers
|
maintainers: steps.step1.output.maintainers
|
||||||
|
sdk_changes: ${{ steps.step3.outputs.sdk_changes }}
|
||||||
runs-on:
|
runs-on:
|
||||||
- ubuntu-latest
|
- ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Fetch members of the maintainers team
|
- name: Fetch members of the maintainers team
|
||||||
|
id: step1
|
||||||
env:
|
env:
|
||||||
requester: ${{ github.event.comment.user.login }}
|
requester: ${{ github.event.comment.user.login }}
|
||||||
shell: bash
|
shell: bash
|
||||||
@ -49,25 +49,30 @@ jobs:
|
|||||||
|
|
||||||
$res
|
$res
|
||||||
|
|
||||||
|
- name: Set outputs
|
||||||
|
id: step2
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
echo "sdk_changes=${{ contains(github.event.comment.body, '/update-sdk') }}" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Post a link to the workflow run to the PR
|
- name: Post a link to the workflow run to the PR
|
||||||
|
id: step3
|
||||||
uses: mshick/add-pr-comment@v2
|
uses: mshick/add-pr-comment@v2
|
||||||
with:
|
with:
|
||||||
issue: ${{ github.event.issue.pull_request.number }}
|
issue: ${{ github.event.issue.pull_request.number }}
|
||||||
message: "Build action triggered: [${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})"
|
message: "Build action triggered: [${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})"
|
||||||
|
|
||||||
update_sdk:
|
update_sdk:
|
||||||
needs: check_maintainer_membership
|
needs: run_pre_checks
|
||||||
if: ( needs.check_maintainer_membership.result == 'success'
|
if: needs.run_pre_checks.result == 'success' && needs.run_pre_checks.outputs.sdk_changes == 'true'
|
||||||
&& contains(github.event.comment.body, '/update-sdk') )
|
|
||||||
name: "Build an updated SDK container"
|
name: "Build an updated SDK container"
|
||||||
# SDK build needs access to bincache ssh secret
|
# SDK build needs access to bincache ssh secret
|
||||||
secrets: inherit
|
secrets: inherit
|
||||||
uses: ./.github/workflows/update-sdk.yaml
|
uses: ./.github/workflows/update-sdk.yaml
|
||||||
|
|
||||||
build_image:
|
build_image:
|
||||||
needs: [ check_maintainer_membership, update_sdk ]
|
needs: [ run_pre_checks, update_sdk ]
|
||||||
if: ( needs.check_maintainer_membership.result == 'success'
|
if: (always() && ! cancelled()) && needs.run_pre_checks.result == 'success' && needs.update_sdk.result != 'failure' && contains(github.event.comment.body, '/build-image')
|
||||||
&& ( contains(github.event.comment.body, '/build-image') || needs.update_sdk.result == 'success' ) )
|
|
||||||
name: "Build the OS image"
|
name: "Build the OS image"
|
||||||
uses: ./.github/workflows/ci.yaml
|
uses: ./.github/workflows/ci.yaml
|
||||||
with:
|
with:
|
||||||
|
49
.github/workflows/pr-workflows.yaml
vendored
Normal file
49
.github/workflows/pr-workflows.yaml
vendored
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
name: "Run PR workflows"
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
pull-requests: write
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-pr-${{ github.head_ref || github.ref_name }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
pre_check:
|
||||||
|
name: "Check if we need to update the SDK"
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
# Setting the environment is the more important reason we need this job.
|
||||||
|
# We use this job as a gate, so we can approve the PR workflow only once. If
|
||||||
|
# we set this in the update_sdk job and in the build_image job, we would have
|
||||||
|
# to approve the workflow for every job that kicks off. Given that the jobs
|
||||||
|
# are sequenced, this is cumbersome. Use this job as a gate and make the rest
|
||||||
|
# dependent on it.
|
||||||
|
environment: development
|
||||||
|
outputs:
|
||||||
|
sdk_changes: ${{ steps.step1.outputs.sdk_changes }}
|
||||||
|
steps:
|
||||||
|
- name: Set outputs
|
||||||
|
id: step1
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
echo "sdk_changes=${{ contains(github.event.pull_request.body, '/update-sdk') }}" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
update_sdk:
|
||||||
|
name: "Build an updated SDK container"
|
||||||
|
needs: [ pre_check ]
|
||||||
|
if: needs.pre_check.outputs.sdk_changes == 'true'
|
||||||
|
# SDK build needs access to bincache ssh secret
|
||||||
|
secrets: inherit
|
||||||
|
uses: ./.github/workflows/update-sdk.yaml
|
||||||
|
|
||||||
|
build_image:
|
||||||
|
needs: [ update_sdk ]
|
||||||
|
# The update-sdk job may be skipped, which is fine. We only care if it tried to
|
||||||
|
# run, but failed.
|
||||||
|
if: (always() && !cancelled()) && needs.update_sdk.result != 'failure'
|
||||||
|
name: "Build the OS image"
|
||||||
|
uses: ./.github/workflows/ci.yaml
|
||||||
|
with:
|
||||||
|
custom_sdk_version: ${{ needs.update_sdk.outputs.sdk_version }}
|
||||||
|
image_formats: qemu_uefi
|
6
.github/workflows/run-kola-tests.yaml
vendored
6
.github/workflows/run-kola-tests.yaml
vendored
@ -243,7 +243,7 @@ jobs:
|
|||||||
set -e
|
set -e
|
||||||
|
|
||||||
- name: Upload detailed test logs
|
- name: Upload detailed test logs
|
||||||
if: always()
|
if: always() && !cancelled()
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: ${{ matrix.arch }}-test-logs-and-results
|
name: ${{ matrix.arch }}-test-logs-and-results
|
||||||
@ -255,7 +255,7 @@ jobs:
|
|||||||
scripts/results-*.md
|
scripts/results-*.md
|
||||||
|
|
||||||
- name: Upload raw TAP files of all runs for later merging
|
- name: Upload raw TAP files of all runs for later merging
|
||||||
if: always()
|
if: always() && !cancelled()
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: ${{ matrix.arch }}-raw-tapfiles
|
name: ${{ matrix.arch }}-raw-tapfiles
|
||||||
@ -266,7 +266,7 @@ jobs:
|
|||||||
merge_and_publish_results:
|
merge_and_publish_results:
|
||||||
name: "Merge TAP reports and post results"
|
name: "Merge TAP reports and post results"
|
||||||
needs: tests
|
needs: tests
|
||||||
if: always()
|
if: always() && !cancelled()
|
||||||
runs-on:
|
runs-on:
|
||||||
- self-hosted
|
- self-hosted
|
||||||
- debian
|
- debian
|
||||||
|
5
.github/workflows/update-sdk.yaml
vendored
5
.github/workflows/update-sdk.yaml
vendored
@ -14,6 +14,10 @@ on:
|
|||||||
Custom SDK container version to build. Defaults to source SDK w/ "-github-[DATE]" appended.
|
Custom SDK container version to build. Defaults to source SDK w/ "-github-[DATE]" appended.
|
||||||
|
|
||||||
workflow_call:
|
workflow_call:
|
||||||
|
outputs:
|
||||||
|
sdk_version:
|
||||||
|
description: "The version of the SDK container that was built"
|
||||||
|
value: ${{ jobs.update_sdk.outputs.sdk_version }}
|
||||||
inputs:
|
inputs:
|
||||||
source_sdk_version:
|
source_sdk_version:
|
||||||
type: string
|
type: string
|
||||||
@ -117,6 +121,7 @@ jobs:
|
|||||||
target_version="${CUSTOM_SDK_VERSION}"
|
target_version="${CUSTOM_SDK_VERSION}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo "setting sdk_version=${target_version} as a github output"
|
||||||
echo "sdk_version=${target_version}" >> "$GITHUB_OUTPUT"
|
echo "sdk_version=${target_version}" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
# This also updates sdk_container/.repo/manifests/version.txt with the new SDK version.
|
# This also updates sdk_container/.repo/manifests/version.txt with the new SDK version.
|
||||||
|
Loading…
Reference in New Issue
Block a user