-
Notifications
You must be signed in to change notification settings - Fork 62
110 lines (97 loc) · 3.84 KB
/
gh-test-external-registry.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
name: test-gh-external-registries
on:
push:
branches:
- develop
pull_request_target:
types: [opened, reopened, synchronize, edited]
permissions:
contents: read
actions: none
checks: none
deployments: none
issues: none
packages: none
pull-requests: none
repository-projects: none
security-events: none
statuses: none
jobs:
test-harbor:
name: Test GH with Harbor
runs-on: ubuntu-latest
environment: TanzuNet Registry Dev e2e
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v3
with:
go-version: '1.21.1'
- name: Check out code into the Go module directory
uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}
path: src/github.com/${{ github.repository }}
persist-credentials: false
- name: Run Tests
env:
IMGPKG_E2E_IMAGE: "dev.registry.tanzu.vmware.com/imgpkg/github-action-test-relocation"
IMGPKG_E2E_RELOCATION_REPO: "dev.registry.tanzu.vmware.com/imgpkg/github-action-imgpkg-test"
TanzuNetDevUsername: ${{ secrets.TanzuNetDevUsername }}
TanzuNetDevPassword: ${{ secrets.TanzuNetDevPassword }}
run: |
set -e
# Prevent conflicts from multiple e2e tests run in parallel from diff PR's
export IMGPKG_E2E_IMAGE="$IMGPKG_E2E_IMAGE-$GITHUB_RUN_ID"
export IMGPKG_E2E_RELOCATION_REPO="$IMGPKG_E2E_RELOCATION_REPO-$GITHUB_RUN_ID"
export GOPATH=$(echo `pwd`)
export PATH="$PATH:$GOPATH/bin"
cd src/github.com/${{ github.repository }}
docker login dev.registry.tanzu.vmware.com -u "$TanzuNetDevUsername" -p "$TanzuNetDevPassword"
# pull registry for e2e tests that require a locally running docker registry. i.e. airgapped env tests
docker pull registry:2
./hack/test-all.sh
test-gcr:
name: Test GH with GCR
runs-on: ubuntu-latest
environment: GCR e2e
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v3
with:
go-version: '1.21.1'
- name: Check out code into the Go module directory
uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}
path: src/github.com/${{ github.repository }}
persist-credentials: false
- name: Run Tests
env:
IMGPKG_E2E_IMAGE: "gcr.io/cf-k8s-lifecycle-tooling-klt/github-action-test-relocation"
IMGPKG_E2E_RELOCATION_REPO: "gcr.io/cf-k8s-lifecycle-tooling-klt/github-action-imgpkg-test"
GCR_PASSWORD: ${{ secrets.GCR_PASSWORD }}
run: |
set -e
# Prevent conflicts from multiple e2e tests run in parallel from diff PR's
export IMGPKG_E2E_IMAGE="$IMGPKG_E2E_IMAGE-$GITHUB_RUN_ID"
export IMGPKG_E2E_RELOCATION_REPO="$IMGPKG_E2E_RELOCATION_REPO-$GITHUB_RUN_ID"
export GOPATH=$(echo `pwd`)
export PATH="$PATH:$GOPATH/bin"
cd src/github.com/${{ github.repository }}
docker login -u _json_key --password-stdin https://gcr.io <<< "$GCR_PASSWORD"
# pull registry for e2e tests that require a locally running docker registry. i.e. airgapped env tests
docker pull registry:2
function cleanup {
set +e
{
gcloud auth activate-service-account --key-file <(echo "$GCR_PASSWORD")
gcloud config set project cf-k8s-lifecycle-tooling-klt > /dev/null
gcloud container images list --filter=$GITHUB_RUN_ID | while read img; do
gcloud container images list-tags $img --format='get(digest)' | while read img_sha_to_delete; do
gcloud container images delete "${img}@${img_sha_to_delete}" --force-delete-tags --quiet
done
done
} > /dev/null
}
trap cleanup EXIT
./hack/test-all.sh