Skip to content

Commit

Permalink
Add GCP support to GLCI (simp#136)
Browse files Browse the repository at this point in the history
This patch updates GHA workflows to use GCP as a hypervisor when
BEAKER_HYPERVISOR is `google`

The patch enforces a standardized asset baseline using simp/puppetsync,
and may also apply other updates to ensure conformity.
  • Loading branch information
rgardner4012 authored Mar 23, 2023
1 parent 7785c41 commit d3dea2d
Show file tree
Hide file tree
Showing 8 changed files with 120 additions and 73 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/pr_glci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
outputs:
valid: ${{ steps.validate-glci-file.outputs.valid }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
Expand All @@ -80,11 +80,11 @@ jobs:

contributor-permissions:
name: 'PR contributor check'
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
outputs:
permitted: ${{ steps.user-repo-permissions.outputs.permitted }}
steps:
- uses: actions/github-script@v3
- uses: actions/github-script@v6
id: user-repo-permissions
with:
github-token: ${{secrets.GITHUB_TOKEN}}
Expand Down Expand Up @@ -135,7 +135,7 @@ jobs:
# - Not implemented: For some reason, this conditional always fails
# - Unnecessary if on>pull_request_target>types doesn't include 'closed'
if: github.event_name == 'pull_request_target' && ( github.event.action == 'opened' || github.event.action == 'reopened' || github.event.action == 'synchronize' ) && github.event.pull_request.merged != 'true' && needs.glci-syntax.outputs.valid == 'true' && needs.contributor-permissions.outputs.permitted == 'true'
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
steps:
# Things we'd like to do:
# - [ ] if there's no GitLab mirror, make one
Expand All @@ -145,7 +145,7 @@ jobs:
# - "created|waiting_for_resource|preparing|pending|running"
# - Exception: don't cancel existing pipeline for our own commit
# - [x] if PR: force-push branch to GitLab
- uses: actions/checkout@v2
- uses: actions/checkout@v3
if: needs.contributor-permissions.outputs.permitted == 'true'
with:
clean: true
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pr_glci_cleanup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ jobs:
# `on` section is inadventently modified without considering the security
# implications.
if: github.event_name == 'pull_request_target' && github.event.action == 'closed'
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/pr_glci_manual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# ------------------------------------------------------------------------------
#
# NOTICE: **This file is maintained with puppetsync**
#

# This file is updated automatically as part of a standardized asset baseline.
#
# The next baseline sync will overwrite any local changes to this file!
Expand Down Expand Up @@ -42,15 +42,15 @@ on:
jobs:
glci-syntax:
name: '.gitlab-ci.yml Syntax'
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
outputs:
valid: ${{ steps.validate-glci-file.outputs.valid }}
pr_head_ref: ${{ steps.get-pr.outputs.pr_head_ref }}
pr_head_sha: ${{ steps.get-pr.outputs.pr_head_sha }}
pr_head_label: ${{ steps.get-pr.outputs.pr_head_label }}
pr_head_full_name: ${{ steps.get-pr.outputs.pr_full_name }}
steps:
- uses: actions/github-script@v3
- uses: actions/github-script@v6
id: get-pr
with:
github-token: ${{secrets.NO_SCOPE_GITHUB_TOKEN}}
Expand Down Expand Up @@ -90,7 +90,7 @@ jobs:
core.setOutput( 'pr_head_ref', pr.data.head.ref )
core.setOutput( 'pr_head_label', pr.data.head.label )
core.setOutput( 'pr_head_full_name', pr.data.head.full_name )
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
repository: ${{ steps.get-pr.outputs.pr_head_full_name }}
ref: ${{ steps.get-pr.outputs.pr_head_sha }}
Expand All @@ -106,9 +106,9 @@ jobs:
trigger-when-user-has-repo-permissions:
name: 'Trigger CI'
needs: [ glci-syntax ]
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
repository: ${{ needs.glci-syntax.outputs.pr_head_full_name }}
ref: ${{ needs.glci-syntax.outputs.pr_head_sha }}
Expand All @@ -129,7 +129,7 @@ jobs:
### needs: [ glci-syntax ]
### name: 'Examine Context contents'
### if: always()
### runs-on: ubuntu-18.04
### runs-on: ubuntu-latest
### steps:
### - name: Dump contexts
### env:
Expand Down
26 changes: 13 additions & 13 deletions .github/workflows/pr_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ env:
jobs:
puppet-syntax:
name: 'Puppet Syntax'
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: "Install Ruby ${{matrix.puppet.ruby_version}}"
uses: ruby/setup-ruby@v1 # ruby/setup-ruby@ec106b438a1ff6ff109590de34ddc62c540232e0
with:
Expand All @@ -44,9 +44,9 @@ jobs:

puppet-style:
name: 'Puppet Style'
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: "Install Ruby ${{matrix.puppet.ruby_version}}"
uses: ruby/setup-ruby@v1
with:
Expand All @@ -58,10 +58,10 @@ jobs:
ruby-style:
if: false # TODO Modules will need: rubocop in Gemfile, .rubocop.yml
name: 'Ruby Style (experimental)'
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
continue-on-error: true
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: "Install Ruby ${{matrix.puppet.ruby_version}}"
uses: ruby/setup-ruby@v1
with:
Expand All @@ -73,9 +73,9 @@ jobs:
file-checks:
name: 'File checks'
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: 'Install Ruby 2.5'
uses: ruby/setup-ruby@v1
with:
Expand All @@ -86,9 +86,9 @@ jobs:

releng-checks:
name: 'RELENG checks'
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: 'Install Ruby ${{matrix.puppet.ruby_version}}'
uses: ruby/setup-ruby@v1
with:
Expand All @@ -97,15 +97,15 @@ jobs:
- name: 'Tags and changelogs'
run: |
bundle exec rake pkg:check_version
bundle exec rake pkg:compare_latest_tag
bundle exec rake pkg:compare_latest_tag[,true]
bundle exec rake pkg:create_tag_changelog
- name: 'Test-build the Puppet module'
run: 'bundle exec pdk build --force'

spec-tests:
name: 'Puppet Spec'
needs: [puppet-syntax]
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
strategy:
matrix:
puppet:
Expand All @@ -118,7 +118,7 @@ jobs:
env:
PUPPET_VERSION: '${{matrix.puppet.puppet_version}}'
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: 'Install Ruby ${{matrix.puppet.ruby_version}}'
uses: ruby/setup-ruby@v1
with:
Expand Down
53 changes: 37 additions & 16 deletions .github/workflows/release_rpms.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,15 @@ on:
description: "Dry run (Test-build RPMs)"
required: false
default: 'no'
verbose:
description: 'Verbose RPM builds when "yes"'
#verbose:
# description: 'Verbose RPM builds when "yes"'
# required: false
# default: 'no'
rebuild_number:
description: 'If this is an RPM rebuild, put the number of the rebuild here'
required: false
default: 'no'
default: ''


env:
TARGET_REPO: ${{ (github.event.inputs.target_repo != null && format('{0}/{1}', github.repository_owner, github.event.inputs.target_repo)) || github.repository }}
Expand All @@ -99,13 +104,13 @@ jobs:
if [[ "$RELEASE_TAG" =~ ^(simp-|v)?([0-9]+\.[0-9]+\.[0-9]+)(-(rc|RC|[Aa]lpha|[Bb]eta|pre|post)?([0-9]+)?)?$ ]]; then
if [ -n "${BASH_REMATCH[5]}" ]; then
echo "::set-output name=prebuild_number::${BASH_REMATCH[5]#-}"
echo "{prebuild_number}={${BASH_REMATCH[5]#-}}" >> $GITHUB_OUTPUT
fi
if [ -n "${BASH_REMATCH[3]}" ]; then
echo "::set-output name=prebuild_suffix::${BASH_REMATCH[3]#-}"
echo "{prebuild_suffix}={${BASH_REMATCH[3]#-}}" >> $GITHUB_OUTPUT
fi
if [ -n "${BASH_REMATCH[2]}" ]; then
echo "::set-output name=build_semver::${BASH_REMATCH[2]}"
echo "{build_semver}={${BASH_REMATCH[2]}}" >> $GITHUB_OUTPUT
fi
else
printf '::error ::Release Tag format is not SemVer, X.Y.Z-R, X.Y.Z-<prerelease>: "%s"\n' "$RELEASE_TAG"
Expand All @@ -121,7 +126,7 @@ jobs:
env:
AUTOCREATE_RELEASE: ${{ github.event.inputs.autocreate_release }}
PREBUILD_TAG: ${{ steps.validate-inputs.outputs.prebuild_suffix }}
uses: actions/github-script@v4
uses: actions/github-script@v6
with:
github-token: ${{ github.event.inputs.target_repo_token || secrets.GITHUB_TOKEN }}
script: |
Expand Down Expand Up @@ -189,7 +194,7 @@ jobs:
)
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
repository: ${{ env.TARGET_REPO }}
ref: ${{ env.RELEASE_TAG }}
Expand Down Expand Up @@ -221,6 +226,22 @@ jobs:
printf '::warning ::Added file build/rpm_metadata/release with content "%s"\n' "$(cat build/rpm_metadata/release)"
fi
- name: 'Customize RPM Release tag via build/rpm_metadata/release (RPM rebuild)'
if: ${{ github.event.inputs.rebuild_number != '' }}
env:
BUILD_SEMVER: ${{ steps.validate-inputs.outputs.build_semver }}
REBUILD_NUMBER: ${{ github.event.inputs.rebuild_number }}
run: |
mkdir -p build/rpm_metadata
# simp-doc uses a unique data format in /release
if [[ "$TARGET_REPO" =~ ^simp\/simp-doc$ ]]; then
echo "version: $BUILD_SEMVER" > build/rpm_metadata/release
echo "release: $REBUILD_NUMBER" > build/rpm_metadata/release
else
echo "$REBUILD_NUMBER" > build/rpm_metadata/release
fi
printf '::warning ::Added file build/rpm_metadata/release with content "%s"\n' "$(cat build/rpm_metadata/release)"
- name: >
Build & Sign RPMs for
${{ github.event.inputs.release_tag }}
Expand All @@ -234,30 +255,30 @@ jobs:
simp_core_ref_for_building_rpms: ${{ secrets.SIMP_CORE_REF_FOR_BUILDING_RPMS }}
simp_builder_docker_image: 'docker.io/simpproject/simp_build_${{ github.event.inputs.build_container_os }}:latest'
path_to_build: "${{ (github.event.inputs.path_to_build != null && format('{0}/{1}', github.workspace, github.event.inputs.path_to_build)) || github.workspace }}"
verbose: ${{ github.event.inputs.verbose }}
verbose: 'no' #${{ github.event.inputs.verbose }}
- name: "Wipe all previous assets from GitHub Release (when clean == 'yes')"
if: ${{ github.event.inputs.clean == 'yes' && github.event.inputs.dry_run != 'yes' }}
uses: actions/github-script@v4
uses: actions/github-script@v6
env:
release_id: ${{ steps.release-api.outputs.id }}
with:
github-token: ${{ github.event.inputs.target_repo_token || secrets.GITHUB_TOKEN }}
script: |
const release_id = process.env.release_id
const [owner, repo] = process.env.TARGET_REPO.split('/')
const existingAssets = await github.repos.listReleaseAssets({ owner, repo, release_id })
const existingAssets = await github.rest.repos.listReleaseAssets({ owner, repo, release_id })
console.log( ` !! !! Wiping ALL uploaded assets for ${owner}/${repo} release (id: ${release_id})`)
existingAssets.data.forEach(async function(asset){
asset_id = asset.id
console.log( ` !! !! !! Wiping existing asset for ${asset.name} (id: ${asset_id})`)
await github.repos.deleteReleaseAsset({ owner, repo, asset_id })
await github.rest.repos.deleteReleaseAsset({ owner, repo, asset_id })
})
- name: "Upload RPM file(s) to GitHub Release (dry_run != 'yes')"
if: ${{ github.event.inputs.dry_run != 'yes' }}
uses: actions/github-script@v4
uses: actions/github-script@v6
env:
rpm_file_paths: ${{ steps.build-and-sign-rpm.outputs.rpm_file_paths }}
rpm_gpg_file: ${{ steps.build-and-sign-rpm.outputs.rpm_gpg_file }}
Expand All @@ -274,12 +295,12 @@ jobs:
async function clobberAsset (name, owner, repo, release_id ){
console.log( ` -- clobber asset ${name}: owner: ${owner} repo: ${repo} release_id: ${release_id}` )
const existingAssets = await github.repos.listReleaseAssets({ owner, repo, release_id })
const existingAssets = await github.rest.repos.listReleaseAssets({ owner, repo, release_id })
const matchingAssets = existingAssets.data.filter(item => item.name == name);
if ( matchingAssets.length > 0 ){
asset_id = matchingAssets[0].id
console.log( ` !! !! Clobbering existing asset for ${name} (id: ${asset_id})`)
await github.repos.deleteReleaseAsset({ owner, repo, asset_id })
await github.rest.repos.deleteReleaseAsset({ owner, repo, asset_id })
return(true)
}
return(false)
Expand All @@ -297,7 +318,7 @@ jobs:
};
console.log( ` == Uploading asset ${name}: ${assetContentType}` )
const uploadAssetResponse = await github.repos.uploadReleaseAsset({
const uploadAssetResponse = await github.rest.repos.uploadReleaseAsset({
owner, repo, release_id, data, name, headers,
})
return( uploadAssetResponse );
Expand Down
Loading

0 comments on commit d3dea2d

Please sign in to comment.