-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
3 changed files
with
165 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
name: test reusable-ko-build | ||
on: | ||
pull_request: {} | ||
workflow_dispatch: {} | ||
env: | ||
VERSION_CRANE: v0.16.1 | ||
|
||
# LIMITATIONS | ||
# - this workflow cannot run in parallel between PRs; retries are required (for now). | ||
# this is due to non-unique image names. having unique image names tends to cause needing to retry more times due to some sort of internal container artifact "registration" behaviour | ||
|
||
# TESTCASES | ||
# - t0: basic | ||
# - t1: auth-with-geonetci | ||
# - t2: with-paths-and-packages | ||
# - t3: no-push | ||
|
||
permissions: | ||
packages: write | ||
contents: read | ||
id-token: write | ||
jobs: | ||
t0-basic: | ||
uses: ./.github/workflows/reusable-ko-build.yml | ||
with: | ||
push: true | ||
setup: | | ||
mkdir -p testdata-ko-build/cmd/testimage-ko-build-t0-basic-1 | ||
cat << EOF > testdata-ko-build/cmd/testimage-ko-build-t0-basic-1/main.go | ||
package main | ||
import "fmt" | ||
func main() { | ||
fmt.Println("Hello World!") | ||
} | ||
EOF | ||
t0-basic-check: | ||
needs: t0-basic | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: GeoNet/setup-crane@00c9e93efa4e1138c9a7a5c594acd6c75a2fbf0c # main | ||
with: | ||
version: ${{ env.VERSION_CRANE }} | ||
- name: check for images | ||
env: | ||
IMAGES: ${{ needs.t0-basic.outputs.images }} | ||
run: | | ||
echo "$IMAGES" | tr ',' '\n' | xargs -n 1 -I{} crane manifest {} | ||
- name: cleanup | ||
if: always() | ||
env: | ||
GH_TOKEN: ${{ github.token }} | ||
run: | | ||
gh api -X DELETE /orgs/GeoNet/packages/container/actions%2Ftestimage-ko-build-t0-basic-1 || true | ||
t1-auth-with-geonetci: | ||
uses: ./.github/workflows/reusable-ko-build.yml | ||
secrets: inherit | ||
with: | ||
push: true | ||
registryGhcrUsernameOverride: geonetci | ||
setup: | | ||
mkdir -p testdata-ko-build/cmd/testimage-ko-build-t1-auth-with-geonetci-1 | ||
cat << EOF > testdata-ko-build/cmd/testimage-ko-build-t1-auth-with-geonetci-1/main.go | ||
package main | ||
import "fmt" | ||
func main() { | ||
fmt.Println("Hello World!") | ||
} | ||
EOF | ||
t1-auth-with-geonetci-check: | ||
needs: t1-auth-with-geonetci | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: GeoNet/setup-crane@00c9e93efa4e1138c9a7a5c594acd6c75a2fbf0c # main | ||
with: | ||
version: ${{ env.VERSION_CRANE }} | ||
- name: check for images | ||
env: | ||
IMAGES: ${{ needs.t1-auth-with-geonetci.outputs.images }} | ||
run: | | ||
echo "$IMAGES" | tr ',' '\n' | xargs -n 1 -I{} crane manifest {} | ||
- name: cleanup | ||
if: always() | ||
env: | ||
GH_TOKEN: ${{ github.token }} | ||
run: | | ||
gh api -X DELETE /orgs/GeoNet/packages/container/actions%2Ftestimage-ko-build-t1-auth-with-geonetci-1 || true | ||
t2-with-paths-and-packages: | ||
uses: ./.github/workflows/reusable-ko-build.yml | ||
with: | ||
push: true | ||
paths: | | ||
./testdata-ko-build/cmd/testimage-ko-build-t2-with-paths-and-packages-1 | ||
github.com/GeoNet/Actions/testdata-ko-build/cmd/testimage-ko-build-t2-with-paths-and-packages-2 | ||
setup: | | ||
mkdir -p testdata-ko-build/cmd/testimage-ko-build-t2-with-paths-and-packages-1 | ||
cat << EOF > testdata-ko-build/cmd/testimage-ko-build-t2-with-paths-and-packages-1/main.go | ||
package main | ||
import "fmt" | ||
func main() { | ||
fmt.Println("Hello World!") | ||
} | ||
EOF | ||
mkdir -p testdata-ko-build/cmd/testimage-ko-build-t2-with-paths-and-packages-2 | ||
cat << EOF > testdata-ko-build/cmd/testimage-ko-build-t2-with-paths-and-packages-2/main.go | ||
package main | ||
import "fmt" | ||
func main() { | ||
fmt.Println("Hello World!") | ||
} | ||
EOF | ||
t2-with-paths-and-packages-check: | ||
needs: t2-with-paths-and-packages | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: GeoNet/setup-crane@00c9e93efa4e1138c9a7a5c594acd6c75a2fbf0c # main | ||
with: | ||
version: ${{ env.VERSION_CRANE }} | ||
- name: check for images | ||
env: | ||
IMAGES: ${{ needs.t2-with-paths-and-packages.outputs.images }} | ||
run: | | ||
echo "$IMAGES" | tr ',' '\n' | sort | cut -d'@' -f1 | xargs | grep -qE '^ghcr.io/geonet/actions/testimage-ko-build-t2-with-paths-and-packages-1 ghcr.io/geonet/actions/testimage-ko-build-t2-with-paths-and-packages-2$' | ||
echo "$IMAGES" | tr ',' '\n' | xargs -n 1 -I{} crane manifest {} | ||
- name: cleanup | ||
if: always() | ||
env: | ||
GH_TOKEN: ${{ github.token }} | ||
run: | | ||
gh api -X DELETE /orgs/GeoNet/packages/container/actions%2Ftestimage-ko-build-t2-with-paths-and-packages-1 || true | ||
gh api -X DELETE /orgs/GeoNet/packages/container/actions%2Ftestimage-ko-build-t2-with-paths-and-packages-2 || true | ||
t3-no-push: | ||
uses: ./.github/workflows/reusable-ko-build.yml | ||
with: | ||
push: false | ||
setup: | | ||
mkdir -p testdata-ko-build/cmd/testimage-ko-build-t3-no-push-1 | ||
cat << EOF > testdata-ko-build/cmd/testimage-ko-build-t3-no-push-1/main.go | ||
package main | ||
import "fmt" | ||
func main() { | ||
fmt.Println("Hello World!") | ||
} | ||
EOF | ||
t3-no-push-check: | ||
needs: t3-no-push | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: GeoNet/setup-crane@00c9e93efa4e1138c9a7a5c594acd6c75a2fbf0c # main | ||
with: | ||
version: ${{ env.VERSION_CRANE }} | ||
- name: check for images | ||
env: | ||
IMAGE: ${{ needs.t3-no-push.outputs.images }} | ||
GH_TOKEN: ${{ github.token }} | ||
run: | | ||
! crane manifest $IMAGE || \ | ||
( | ||
gh api -X DELETE /orgs/GeoNet/packages/container/actions%2Ftestimage-ko-build-t3-no-push-1 || true | ||
) |
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,3 @@ | ||
module github.com/GeoNet/Actions | ||
|
||
go 1.20 |