This repository has been archived by the owner on Oct 26, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
170 lines (146 loc) · 5.6 KB
/
tests.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
name: Tests
"on":
pull_request: {}
push:
branches:
- main
jobs:
create-package:
name: Create Package Test
runs-on:
- ubuntu-latest
steps:
- uses: actions/setup-go@v2
with:
go-version: "1.16"
- name: Install create-package
run: |
#!/usr/bin/env bash
set -euo pipefail
GO111MODULE=on go get -u -ldflags="-s -w" github.com/paketo-buildpacks/libpak/cmd/create-package
- name: Install pack
run: |
#!/usr/bin/env bash
set -euo pipefail
echo "Installing pack ${PACK_VERSION}"
mkdir -p "${HOME}"/bin
echo "${HOME}/bin" >> "${GITHUB_PATH}"
curl \
--location \
--show-error \
--silent \
"https://github.com/buildpacks/pack/releases/download/v${PACK_VERSION}/pack-v${PACK_VERSION}-linux.tgz" \
| tar -C "${HOME}"/bin -xz pack
env:
PACK_VERSION: 0.18.1
- name: Enable pack Experimental
if: ${{ false }}
run: |
#!/usr/bin/env bash
set -euo pipefail
echo "Enabling pack experimental features"
mkdir -p "${HOME}"/.pack
echo "experimental = true" >> "${HOME}"/.pack/config.toml
- uses: actions/checkout@v2
- uses: actions/cache@v2
with:
key: ${{ runner.os }}-go-${{ hashFiles('**/buildpack.toml', '**/package.toml') }}
path: |-
${{ env.HOME }}/.pack
${{ env.HOME }}/carton-cache
restore-keys: ${{ runner.os }}-go-
- name: Compute Version
id: version
run: |
#!/usr/bin/env bash
set -euo pipefail
if [[ ${GITHUB_REF} =~ refs/tags/v([0-9]+\.[0-9]+\.[0-9]+) ]]; then
VERSION=${BASH_REMATCH[1]}
elif [[ ${GITHUB_REF} =~ refs/heads/(.+) ]]; then
VERSION=${BASH_REMATCH[1]}
else
VERSION=$(git rev-parse --short HEAD)
fi
echo "::set-output name=version::${VERSION}"
echo "Selected ${VERSION} from
* ref: ${GITHUB_REF}
* sha: ${GITHUB_SHA}
"
- name: Create Package
run: |
#!/usr/bin/env bash
set -euo pipefail
if [[ "${INCLUDE_DEPENDENCIES}" == "true" ]]; then
create-package \
--cache-location "${HOME}"/carton-cache \
--destination "${HOME}"/buildpack \
--include-dependencies \
--version "${VERSION}"
else
create-package \
--destination "${HOME}"/buildpack \
--version "${VERSION}"
fi
[[ -e package.toml ]] && cp package.toml "${HOME}"/package.toml
printf '[buildpack]\nuri = "%s"\n\n[platform]\nos = "%s"\n' "${HOME}"/buildpack "${OS}" >> "${HOME}"/package.toml
env:
INCLUDE_DEPENDENCIES: "true"
OS: linux
VERSION: ${{ steps.version.outputs.version }}
- name: Package Buildpack
run: |
#!/usr/bin/env bash
set -euo pipefail
if [[ -n "${PUBLISH+x}" ]]; then
pack buildpack package \
"${PACKAGE}:${VERSION}" \
--config "${HOME}"/package.toml \
--publish
crane tag "${PACKAGE}:${VERSION}" latest
echo "::set-output name=digest::$(crane digest "${PACKAGE}:${VERSION}")"
else
pack buildpack package \
"${PACKAGE}:${VERSION}" \
--config "${HOME}"/package.toml \
--format "${FORMAT}"
fi
env:
FORMAT: image
PACKAGE: test
VERSION: ${{ steps.version.outputs.version }}
unit:
name: Unit Test
runs-on:
- ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
with:
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
path: ${{ env.HOME }}/go/pkg/mod
restore-keys: ${{ runner.os }}-go-
- uses: actions/setup-go@v2
with:
go-version: "1.16"
- name: Install richgo
run: |
#!/usr/bin/env bash
set -euo pipefail
echo "Installing richgo ${RICHGO_VERSION}"
mkdir -p "${HOME}"/bin
echo "${HOME}/bin" >> "${GITHUB_PATH}"
curl \
--location \
--show-error \
--silent \
"https://github.com/kyoh86/richgo/releases/download/v${RICHGO_VERSION}/richgo_${RICHGO_VERSION}_linux_amd64.tar.gz" \
| tar -C "${HOME}"/bin -xz richgo
env:
RICHGO_VERSION: 0.3.6
- name: Run Tests
run: |
#!/usr/bin/env bash
set -euo pipefail
richgo test ./...
env:
RICHGO_FORCE_COLOR: "1"