Skip to content

Commit c34940c

Browse files
pacostaspaketo-botthitch97
authored
Automation/GitHub config/update with fixed integration issues (#46)
* 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]>
1 parent f246857 commit c34940c

File tree

5 files changed

+91
-88
lines changed

5 files changed

+91
-88
lines changed

.github/workflows/create-draft-release.yml

+28-5
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
- name: Setup Go
2525
uses: actions/setup-go@v3
2626
with:
27-
go-version: 1.20.x
27+
go-version: 'stable'
2828
- name: Checkout
2929
uses: actions/checkout@v3
3030
- name: Run Unit Tests
@@ -37,18 +37,41 @@ jobs:
3737
printf "Output: %s\n" "${builders}"
3838
printf "builders=%s\n" "${builders}" >> "$GITHUB_OUTPUT"
3939
40+
integration:
41+
name: Integration Tests with Builders
42+
runs-on: ubuntu-22.04
43+
needs: unit
44+
strategy:
45+
matrix:
46+
builder: ${{ fromJSON(needs.unit.outputs.builders) }}
47+
fail-fast: false # don't cancel all test jobs when one fails
48+
steps:
49+
- name: Setup Go
50+
uses: actions/setup-go@v3
51+
with:
52+
go-version: 'stable'
53+
54+
- name: Checkout
55+
uses: actions/checkout@v3
56+
57+
- name: Run Integration Tests
58+
run: ./scripts/integration.sh --builder ${{ matrix.builder }} --token ${{ github.token }}
59+
env:
60+
TMPDIR: "${{ runner.temp }}"
61+
4062
release:
4163
name: Release
4264
runs-on: ubuntu-22.04
43-
needs: unit
65+
needs: integration
4466
steps:
4567
- name: Setup Go
4668
uses: actions/setup-go@v3
4769
with:
48-
go-version: 1.20.x
70+
go-version: 'stable'
4971
- name: Checkout
5072
uses: actions/checkout@v3
51-
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* || true
73+
with:
74+
fetch-tags: true
5275
- name: Reset Draft Release
5376
id: reset
5477
uses: paketo-buildpacks/github-config/actions/release/reset-draft@main
@@ -104,7 +127,7 @@ jobs:
104127
failure:
105128
name: Alert on Failure
106129
runs-on: ubuntu-22.04
107-
needs: [ unit, release ]
130+
needs: [ unit, integration, release ]
108131
if: ${{ always() && needs.unit.result == 'failure' || needs.integration.result == 'failure' || needs.release.result == 'failure' }}
109132
steps:
110133
- name: File Failure Alert Issue

.github/workflows/test-pull-request.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,8 @@ jobs:
5555
uses: actions/checkout@v3
5656

5757
- name: Run Integration Tests
58-
run: ./scripts/integration.sh --use-token --builder ${{ matrix.builder }}
58+
run: ./scripts/integration.sh --builder ${{ matrix.builder }} --token ${{ github.token }}
5959
env:
60-
GIT_TOKEN: ${{ github.token }}
6160
TMPDIR: "${{ runner.temp }}"
6261

6362
roundup:

scripts/.util/git.sh

-21
This file was deleted.

scripts/.util/tools.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"createpackage": "v1.67.2",
3-
"jam": "v2.6.0",
4-
"pack": "v0.31.0"
3+
"jam": "v2.7.0",
4+
"pack": "v0.32.0"
55
}

scripts/integration.sh

+60-58
Original file line numberDiff line numberDiff line change
@@ -12,68 +12,68 @@ source "${PROGDIR}/.util/tools.sh"
1212
# shellcheck source=SCRIPTDIR/.util/print.sh
1313
source "${PROGDIR}/.util/print.sh"
1414

15-
# shellcheck source=SCRIPTDIR/.util/git.sh
16-
source "${PROGDIR}/.util/git.sh"
17-
1815
# shellcheck source=SCRIPTDIR/.util/builders.sh
1916
source "${PROGDIR}/.util/builders.sh"
2017

2118
function main() {
22-
local builderArray
19+
local builderArray token
2320
builderArray=()
21+
token=""
22+
2423
while [[ "${#}" != 0 ]]; do
2524
case "${1}" in
26-
--use-token|-t)
25+
--help|-h)
26+
shift 1
27+
usage
28+
exit 0
29+
;;
30+
31+
--builder|-b)
32+
builderArray+=("${2}")
33+
shift 2
34+
;;
35+
36+
--token|-t)
37+
token="${2}"
38+
shift 2
39+
;;
40+
41+
"")
42+
# skip if the argument is empty
2743
shift 1
28-
token::fetch
2944
;;
3045

31-
--help | -h)
32-
shift 1
33-
usage
34-
exit 0
35-
;;
36-
37-
--builder | -b)
38-
builderArray+=("${2}")
39-
shift 2
40-
;;
41-
42-
"")
43-
# skip if the argument is empty
44-
shift 1
45-
;;
46-
47-
*)
48-
util::print::error "unknown argument \"${1}\""
49-
;;
46+
*)
47+
util::print::error "unknown argument \"${1}\""
5048
esac
5149
done
5250

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

57-
tools::install
55+
tools::install "${token}"
5856

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

6260
local builders
63-
builders="$(util::builders::list "${BUILDPACKDIR}/integration.json" | jq -r '.[]')"
61+
builders="$(util::builders::list "${BUILDPACKDIR}/integration.json" | jq -r '.[]' )"
62+
63+
util::print::info "Found the following builders:"
64+
util::print::info "${builders}"
6465

6566
# shellcheck disable=SC2206
6667
IFS=$'\n' builderArray=(${builders})
6768
unset IFS
6869
fi
6970

70-
# shellcheck disable=SC2068
71-
images::pull ${builderArray[@]}
72-
7371
local testout
7472
testout=$(mktemp)
75-
7673
for builder in "${builderArray[@]}"; do
74+
util::print::title "Getting images for builder: '${builder}'"
75+
builder_images::pull "${builder}"
76+
7777
util::print::title "Setting default pack builder image..."
7878
pack config default-builder "${builder}"
7979

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

100101
function tools::install() {
101102

102103
util::tools::pack::install \
103-
--directory "${BUILDPACKDIR}/.bin"
104+
--directory "${BUILDPACKDIR}/.bin" \
105+
--token "${token}"
104106

105107
util::tools::jam::install \
106-
--directory "${BUILDPACKDIR}/.bin"
108+
--directory "${BUILDPACKDIR}/.bin" \
109+
--token "${token}"
107110

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

117-
function images::pull() {
118-
for builder in "${@}"; do
119-
util::print::title "Pulling builder image ${builder}..."
120-
docker pull "${builder}"
121-
local run_image lifecycle_image
122-
run_image="$(
123-
pack inspect-builder "${builder}" --output json |
124-
jq -r '.remote_info.run_images[0].name'
125-
)"
126-
lifecycle_image="index.docker.io/buildpacksio/lifecycle:$(
127-
pack inspect-builder "${builder}" --output json |
128-
jq -r '.remote_info.lifecycle.version'
129-
)"
130-
util::print::title "Pulling run image..."
131-
docker pull "${run_image}"
132-
133-
util::print::title "Pulling lifecycle image..."
134-
docker pull "${lifecycle_image}"
135-
done
136-
}
120+
function builder_images::pull() {
121+
local builder
122+
builder="${1}"
123+
124+
util::print::title "Pulling builder image ${builder}..."
125+
docker pull "${builder}"
126+
127+
local run_image lifecycle_image
128+
run_image="$(
129+
pack inspect-builder "${builder}" --output json \
130+
| jq -r '.remote_info.run_images[0].name'
131+
)"
132+
lifecycle_image="index.docker.io/buildpacksio/lifecycle:$(
133+
pack inspect-builder "${builder}" --output json \
134+
| jq -r '.remote_info.lifecycle.version'
135+
)"
136+
137+
util::print::title "Pulling run image..."
138+
docker pull "${run_image}"
137139

138-
function token::fetch() {
139-
GIT_TOKEN="$(util::git::token::fetch)"
140-
export GIT_TOKEN
140+
util::print::title "Pulling lifecycle image..."
141+
docker pull "${lifecycle_image}"
141142
}
142143

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

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

0 commit comments

Comments
 (0)