Skip to content

Commit

Permalink
Updating github-config
Browse files Browse the repository at this point in the history
  • Loading branch information
paketo-bot committed Feb 3, 2023
1 parent 8dcaf0a commit 527c5d8
Show file tree
Hide file tree
Showing 11 changed files with 202 additions and 11 deletions.
27 changes: 23 additions & 4 deletions .github/workflows/approve-bot-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
download:
name: Download PR Artifact
if: ${{ github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
outputs:
pr-author: ${{ steps.pr-data.outputs.author }}
pr-number: ${{ steps.pr-data.outputs.number }}
Expand All @@ -25,14 +25,14 @@ jobs:
token: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }}
- id: pr-data
run: |
echo "::set-output name=author::$(cat event.json | jq -r '.pull_request.user.login')"
echo "::set-output name=number::$(cat event.json | jq -r '.pull_request.number')"
echo "author=$(cat event.json | jq -r '.pull_request.user.login')" >> "$GITHUB_OUTPUT"
echo "number=$(cat event.json | jq -r '.pull_request.number')" >> "$GITHUB_OUTPUT"
approve:
name: Approve Bot PRs
needs: download
if: ${{ needs.download.outputs.pr-author == 'paketo-bot' || needs.download.outputs.pr-author == 'dependabot[bot]' }}
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- name: Check Commit Verification
id: unverified-commits
Expand Down Expand Up @@ -67,3 +67,22 @@ jobs:
gh pr merge ${{ needs.download.outputs.pr-number }} --auto --rebase
env:
GITHUB_TOKEN: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }}

failure:
name: Alert on Failure
runs-on: ubuntu-22.04
needs: [download, approve]
if: ${{ always() && needs.download.result == 'failure' || needs.approve.result == 'failure' }}
steps:
- name: File Failure Alert Issue
uses: paketo-buildpacks/github-config/actions/issue/file@main
with:
token: ${{ secrets.GITHUB_TOKEN }}
repo: ${{ github.repository }}
label: "failure:approve-bot-pr"
comment_if_exists: true
issue_title: "Failure: Approve bot PR workflow"
issue_body: |
Approve bot PR workflow [failed](https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}).
comment_body: |
Another failure occurred: https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ on:
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
runs-on: ubuntu-22.04

strategy:
fail-fast: false
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/label-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ concurrency: pr_labels_${{ github.event.number }}
jobs:
autolabel:
name: Ensure Minimal Semver Labels
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- name: Check Minimal Semver Labels
uses: mheap/github-action-required-labels@v1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint-yaml.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

jobs:
lintYaml:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ on:
jobs:
golangci:
name: lint
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: 1.18.x
go-version: 1.19.x

- name: Checkout
uses: actions/checkout@v3
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/synchronize-labels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ on:
- v*
paths:
- .github/labels.yml
workflow_dispatch: {}

jobs:
synchronize:
name: Synchronize Labels
runs-on:
- ubuntu-latest
- ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: micnncim/action-label-syncer@v1
Expand Down
22 changes: 21 additions & 1 deletion .github/workflows/update-github-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ concurrency: github_config_update
jobs:
build:
name: Create PR to update shared files
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:

- name: Checkout
Expand Down Expand Up @@ -60,3 +60,23 @@ jobs:
token: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }}
title: "Updates github-config"
branch: automation/github-config/update
base: ${{ github.event.repository.default_branch }}

failure:
name: Alert on Failure
runs-on: ubuntu-22.04
needs: [build]
if: ${{ always() && needs.build.result == 'failure' }}
steps:
- name: File Failure Alert Issue
uses: paketo-buildpacks/github-config/actions/issue/file@main
with:
token: ${{ secrets.GITHUB_TOKEN }}
repo: ${{ github.repository }}
label: "failure:update-github-config"
comment_if_exists: true
issue_title: "Failure: Update GitHub config workflow"
issue_body: |
Update GitHub config workflow [failed](https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}).
comment_body: |
Another failure occurred: https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}
21 changes: 21 additions & 0 deletions scripts/.util/git.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash

set -eu
set -o pipefail

# shellcheck source=SCRIPTDIR/print.sh
source "$(dirname "${BASH_SOURCE[0]}")/print.sh"

function util::git::token::fetch() {
if [[ -z "${GIT_TOKEN:-""}" ]]; then
util::print::title "Fetching GIT_TOKEN"

GIT_TOKEN="$(
lpass show Shared-CF\ Buildpacks/concourse-private.yml \
| grep buildpacks-github-token \
| cut -d ' ' -f 2
)"
fi

printf "%s" "${GIT_TOKEN}"
}
51 changes: 51 additions & 0 deletions scripts/.util/print.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/usr/bin/env bash

set -eu
set -o pipefail

function util::print::title() {
local blue reset message
blue="\033[0;34m"
reset="\033[0;39m"
message="${1}"

echo -e "\n${blue}${message}${reset}" >&2
}

function util::print::info() {
local message
message="${1}"

echo -e "${message}" >&2
}

function util::print::error() {
local message red reset
message="${1}"
red="\033[0;31m"
reset="\033[0;39m"

echo -e "${red}${message}${reset}" >&2
exit 1
}

function util::print::success() {
local message green reset
message="${1}"
green="\033[0;32m"
reset="\033[0;39m"

echo -e "${green}${message}${reset}" >&2
exitcode="${2:-0}"
exit "${exitcode}"
}

function util::print::warn() {
local message yellow reset
message="${1}"
yellow="\033[0;33m"
reset="\033[0;39m"

echo -e "${yellow}${message}${reset}" >&2
exit 0
}
17 changes: 17 additions & 0 deletions scripts/.util/tools.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash

set -eu
set -o pipefail

# shellcheck source=SCRIPTDIR/print.sh
source "$(dirname "${BASH_SOURCE[0]}")/print.sh"

function util::tools::tests::checkfocus() {
testout="${1}"
if grep -q 'Focused: [1-9]' "${testout}"; then
echo "Detected Focused Test(s) - setting exit code to 197"
rm "${testout}"
util::print::success "** GO Test Succeeded **" 197
fi
rm "${testout}"
}
62 changes: 62 additions & 0 deletions scripts/unit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/usr/bin/env bash

set -eu
set -o pipefail

readonly PROGDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
readonly BUILDPACKDIR="$(cd "${PROGDIR}/.." && pwd)"

# shellcheck source=SCRIPTDIR/.util/tools.sh
source "${PROGDIR}/.util/tools.sh"

# shellcheck source=SCRIPTDIR/.util/print.sh
source "${PROGDIR}/.util/print.sh"

function main() {
while [[ "${#}" != 0 ]]; do
case "${1}" in
--help|-h)
shift 1
usage
exit 0
;;

"")
# skip if the argument is empty
shift 1
;;

*)
util::print::error "unknown argument \"${1}\""
esac
done

unit::run
}

function usage() {
cat <<-USAGE
unit.sh [OPTIONS]
Runs the unit test suite.
OPTIONS
--help -h prints the command usage
USAGE
}

function unit::run() {
util::print::title "Run Library pack Unit and Example Tests"

testout=$(mktemp)
pushd "${BUILDPACKDIR}" > /dev/null
if go test ./... -v | tee "${testout}"; then
util::tools::tests::checkfocus "${testout}"
util::print::success "** GO Test Succeeded **"
else
util::print::error "** GO Test Failed **"
fi
popd > /dev/null
}

main "${@:-}"

0 comments on commit 527c5d8

Please sign in to comment.