Skip to content

Commit

Permalink
Automation/GitHub config/update with fixed integration issues (#46)
Browse files Browse the repository at this point in the history
* Updating github-config

* Updating github-config

* Updating github-config

* Updating github-config

* Updating github-config

* Updating github-config

* Updating github-config

* fix: adding stable version of go in create-draft-release

* fix: adding integration tests on create-draft-release workflow

* adding token cli arg on integration tests instead of use-token

* fix: removed unused function

* fix: usding fech-tag attribut for fetching the tags

---------

Co-authored-by: paketo-bot <[email protected]>
Co-authored-by: Tim Hitchener <[email protected]>
  • Loading branch information
3 people authored Nov 17, 2023
1 parent f246857 commit c34940c
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 88 deletions.
33 changes: 28 additions & 5 deletions .github/workflows/create-draft-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: 1.20.x
go-version: 'stable'
- name: Checkout
uses: actions/checkout@v3
- name: Run Unit Tests
Expand All @@ -37,18 +37,41 @@ jobs:
printf "Output: %s\n" "${builders}"
printf "builders=%s\n" "${builders}" >> "$GITHUB_OUTPUT"
integration:
name: Integration Tests with Builders
runs-on: ubuntu-22.04
needs: unit
strategy:
matrix:
builder: ${{ fromJSON(needs.unit.outputs.builders) }}
fail-fast: false # don't cancel all test jobs when one fails
steps:
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: 'stable'

- name: Checkout
uses: actions/checkout@v3

- name: Run Integration Tests
run: ./scripts/integration.sh --builder ${{ matrix.builder }} --token ${{ github.token }}
env:
TMPDIR: "${{ runner.temp }}"

release:
name: Release
runs-on: ubuntu-22.04
needs: unit
needs: integration
steps:
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: 1.20.x
go-version: 'stable'
- name: Checkout
uses: actions/checkout@v3
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* || true
with:
fetch-tags: true
- name: Reset Draft Release
id: reset
uses: paketo-buildpacks/github-config/actions/release/reset-draft@main
Expand Down Expand Up @@ -104,7 +127,7 @@ jobs:
failure:
name: Alert on Failure
runs-on: ubuntu-22.04
needs: [ unit, release ]
needs: [ unit, integration, release ]
if: ${{ always() && needs.unit.result == 'failure' || needs.integration.result == 'failure' || needs.release.result == 'failure' }}
steps:
- name: File Failure Alert Issue
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/test-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,8 @@ jobs:
uses: actions/checkout@v3

- name: Run Integration Tests
run: ./scripts/integration.sh --use-token --builder ${{ matrix.builder }}
run: ./scripts/integration.sh --builder ${{ matrix.builder }} --token ${{ github.token }}
env:
GIT_TOKEN: ${{ github.token }}
TMPDIR: "${{ runner.temp }}"

roundup:
Expand Down
21 changes: 0 additions & 21 deletions scripts/.util/git.sh

This file was deleted.

4 changes: 2 additions & 2 deletions scripts/.util/tools.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"createpackage": "v1.67.2",
"jam": "v2.6.0",
"pack": "v0.31.0"
"jam": "v2.7.0",
"pack": "v0.32.0"
}
118 changes: 60 additions & 58 deletions scripts/integration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,68 +12,68 @@ 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"

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

function main() {
local builderArray
local builderArray token
builderArray=()
token=""

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

--builder|-b)
builderArray+=("${2}")
shift 2
;;

--token|-t)
token="${2}"
shift 2
;;

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

--help | -h)
shift 1
usage
exit 0
;;

--builder | -b)
builderArray+=("${2}")
shift 2
;;

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

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

if [[ ! -d "${BUILDPACKDIR}/integration" ]]; then
util::print::warn "** WARNING No Integration tests **"
util::print::warn "** WARNING No Integration tests **"
fi

tools::install
tools::install "${token}"

if [ ${#builderArray[@]} -eq 0 ]; then
util::print::title "No builders provided. Finding builders in integration.json..."

local builders
builders="$(util::builders::list "${BUILDPACKDIR}/integration.json" | jq -r '.[]')"
builders="$(util::builders::list "${BUILDPACKDIR}/integration.json" | jq -r '.[]' )"

util::print::info "Found the following builders:"
util::print::info "${builders}"

# shellcheck disable=SC2206
IFS=$'\n' builderArray=(${builders})
unset IFS
fi

# shellcheck disable=SC2068
images::pull ${builderArray[@]}

local testout
testout=$(mktemp)

for builder in "${builderArray[@]}"; do
util::print::title "Getting images for builder: '${builder}'"
builder_images::pull "${builder}"

util::print::title "Setting default pack builder image..."
pack config default-builder "${builder}"

Expand All @@ -94,16 +94,19 @@ OPTIONS
--help -h prints the command usage
--builder <name> -b <name> sets the name of the builder(s) that are pulled / used for testing.
Defaults to "builders" array in integration.json, if present.
--token <token> Token used to download assets from GitHub (e.g. jam, pack, etc) (optional)
USAGE
}

function tools::install() {

util::tools::pack::install \
--directory "${BUILDPACKDIR}/.bin"
--directory "${BUILDPACKDIR}/.bin" \
--token "${token}"

util::tools::jam::install \
--directory "${BUILDPACKDIR}/.bin"
--directory "${BUILDPACKDIR}/.bin" \
--token "${token}"

util::tools::create-package::install \
--directory "${BUILDPACKDIR}/.bin"
Expand All @@ -114,38 +117,37 @@ function tools::install() {
fi
}

function images::pull() {
for builder in "${@}"; do
util::print::title "Pulling builder image ${builder}..."
docker pull "${builder}"
local run_image lifecycle_image
run_image="$(
pack inspect-builder "${builder}" --output json |
jq -r '.remote_info.run_images[0].name'
)"
lifecycle_image="index.docker.io/buildpacksio/lifecycle:$(
pack inspect-builder "${builder}" --output json |
jq -r '.remote_info.lifecycle.version'
)"
util::print::title "Pulling run image..."
docker pull "${run_image}"

util::print::title "Pulling lifecycle image..."
docker pull "${lifecycle_image}"
done
}
function builder_images::pull() {
local builder
builder="${1}"

util::print::title "Pulling builder image ${builder}..."
docker pull "${builder}"

local run_image lifecycle_image
run_image="$(
pack inspect-builder "${builder}" --output json \
| jq -r '.remote_info.run_images[0].name'
)"
lifecycle_image="index.docker.io/buildpacksio/lifecycle:$(
pack inspect-builder "${builder}" --output json \
| jq -r '.remote_info.lifecycle.version'
)"

util::print::title "Pulling run image..."
docker pull "${run_image}"

function token::fetch() {
GIT_TOKEN="$(util::git::token::fetch)"
export GIT_TOKEN
util::print::title "Pulling lifecycle image..."
docker pull "${lifecycle_image}"
}

function tests::run() {
util::print::title "Run Buildpack Runtime Integration Tests"
util::print::info "Using ${1} as builder..."

export CGO_ENABLED=0
pack config experimental true
pushd "${BUILDPACKDIR}" >/dev/null
pushd "${BUILDPACKDIR}" > /dev/null
if GOMAXPROCS="${GOMAXPROCS:-4}" go test -count=1 -timeout 0 ./integration/... -v -run Integration | tee "${2}"; then
util::print::info "** GO Test Succeeded with ${1}**"
else
Expand Down

0 comments on commit c34940c

Please sign in to comment.