-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add update-github-config workflow to sync from github-config/library
- Loading branch information
1 parent
9c33469
commit 54dcc85
Showing
9 changed files
with
296 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
name: Update shared github-config | ||
|
||
on: | ||
schedule: | ||
- cron: '30 1 * * *' | ||
workflow_dispatch: {} | ||
|
||
concurrency: github_config_update | ||
|
||
jobs: | ||
build: | ||
name: Create PR to update shared files | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
token: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }} | ||
|
||
- name: Checkout github-config | ||
uses: actions/checkout@v3 | ||
with: | ||
repository: paketo-buildpacks/github-config | ||
path: github-config | ||
|
||
- name: Checkout Branch | ||
uses: paketo-buildpacks/github-config/actions/pull-request/checkout-branch@main | ||
with: | ||
branch: automation/github-config/update | ||
|
||
- name: Run the sync action | ||
uses: paketo-buildpacks/github-config/actions/sync@main | ||
with: | ||
workspace: /github/workspace | ||
config: /github/workspace/github-config/library | ||
|
||
- name: Cleanup | ||
run: rm -rf github-config | ||
|
||
- name: Commit | ||
id: commit | ||
uses: paketo-buildpacks/github-config/actions/pull-request/create-commit@main | ||
with: | ||
message: "Updating github-config" | ||
pathspec: "." | ||
keyid: ${{ secrets.PAKETO_BOT_GPG_SIGNING_KEY_ID }} | ||
key: ${{ secrets.PAKETO_BOT_GPG_SIGNING_KEY }} | ||
|
||
- name: Push Branch | ||
if: ${{ steps.commit.outputs.commit_sha != '' }} | ||
uses: paketo-buildpacks/github-config/actions/pull-request/push-branch@main | ||
with: | ||
branch: automation/github-config/update | ||
|
||
- name: Open Pull Request | ||
if: ${{ steps.commit.outputs.commit_sha != '' }} | ||
uses: paketo-buildpacks/github-config/actions/pull-request/open@main | ||
with: | ||
token: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }} | ||
title: "Updates github-config" | ||
branch: automation/github-config/update |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
#!/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" | ||
|
||
# shellcheck source=SCRIPTDIR/.util/git.sh | ||
source "${PROGDIR}/.util/git.sh" | ||
|
||
function main() { | ||
while [[ "${#}" != 0 ]]; do | ||
case "${1}" in | ||
--use-token|-t) | ||
shift 1 | ||
token::fetch | ||
;; | ||
|
||
--help|-h) | ||
shift 1 | ||
usage | ||
exit 0 | ||
;; | ||
|
||
"") | ||
# skip if the argument is empty | ||
shift 1 | ||
;; | ||
|
||
*) | ||
util::print::error "unknown argument \"${1}\"" | ||
esac | ||
done | ||
|
||
if [[ ! -d "${BUILDPACKDIR}/integration" ]]; then | ||
util::print::warn "** WARNING No Integration tests **" | ||
fi | ||
|
||
tests::run | ||
} | ||
|
||
function usage() { | ||
cat <<-USAGE | ||
integration.sh [OPTIONS] | ||
Runs the integration test suite. | ||
OPTIONS | ||
--help -h prints the command usage | ||
--use-token -t use GIT_TOKEN from lastpass | ||
USAGE | ||
} | ||
|
||
function token::fetch() { | ||
GIT_TOKEN="$(util::git::token::fetch)" | ||
export GIT_TOKEN | ||
} | ||
|
||
function tests::run() { | ||
util::print::title "Run Library Integration Tests" | ||
|
||
testout=$(mktemp) | ||
pushd "${BUILDPACKDIR}" > /dev/null | ||
if GOMAXPROCS="${GOMAXPROCS:-4}" go test -count=1 -timeout 0 ./integration/... -v -run Integration | 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 "${@:-}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 -run "Unit|Example" | 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 "${@:-}" |