Skip to content

Commit d56a80c

Browse files
committed
Revert "Sync .github dir templates"
This reverts commit 5e6377e.
1 parent 13aa8d2 commit d56a80c

4 files changed

Lines changed: 468 additions & 0 deletions

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Generate github actions from template
2+
3+
ytt -f ./gh_template.yml -f [ytt-helpers.star](https://github.com/cloudfoundry/wg-app-platform-runtime-ci/blob/main/shared/helpers/ytt-helpers.star) -f [index.yml](https://github.com/cloudfoundry/wg-app-platform-runtime-ci/blob/main/ci-networking-release/index.yml) > ./workflows/tests-workflow.yml
4+
5+
## Supported jobs
6+
- Template tests
7+
- Basic Verifications
8+
- Unit and Integration tests
9+
10+
### How to run
11+
12+
Request the repo owner to add a label as `ready-to-run` to validate PR.
Lines changed: 216 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,216 @@
1+
#@ load("@ytt:data", "data")
2+
#@ load("ytt-helpers.star", "helpers")
3+
name: unit-integration-tests
4+
5+
on:
6+
pull_request:
7+
types: [opened, synchronize, reopened, labeled]
8+
branches:
9+
- develop
10+
paths:
11+
- 'src/**'
12+
- 'packages/**'
13+
- 'jobs/**'
14+
- 'config/**'
15+
- 'scripts/**'
16+
- '.github/workflows/**'
17+
- '.github/helpers/**'
18+
19+
env:
20+
MAPPING: |
21+
build_nats_server=src/code.cloudfoundry.org/vendor/github.com/nats-io/nats-server/v2
22+
FLAGS: |
23+
--keep-going
24+
--trace
25+
-r
26+
--fail-on-pending
27+
--randomize-all
28+
--nodes=7
29+
--race
30+
--timeout 30m
31+
--flake-attempts 2
32+
RUN_AS: root
33+
VERIFICATIONS: |
34+
verify_go repo/$DIR
35+
verify_go_version_match_bosh_release repo
36+
verify_gofmt repo/$DIR
37+
verify_govet repo/$DIR
38+
verify_staticcheck repo/$DIR
39+
FUNCTIONS: ""
40+
DB: ""
41+
42+
jobs:
43+
repo-clone:
44+
runs-on: ubuntu-latest
45+
steps:
46+
- name: cf-networking-release-repo
47+
uses: actions/checkout@v4.3.1
48+
with:
49+
repository: ${{ github.event.pull_request.head.repo.full_name }}
50+
ref: ${{ github.event.pull_request.head.ref }}
51+
submodules: recursive
52+
path: repo
53+
- name: Check out wg-appruntime code
54+
uses: actions/checkout@v4.3.1
55+
with:
56+
repository: cloudfoundry/wg-app-platform-runtime-ci
57+
path: ci
58+
- name: zip repo artifacts
59+
run: |
60+
tar -czf repo-artifact.tar.gz repo
61+
tar -czf ci-artifact.tar.gz ci
62+
- name: upload artifact
63+
uses: actions/upload-artifact@v4
64+
with:
65+
name: repo
66+
path: |
67+
repo-artifact.tar.gz
68+
ci-artifact.tar.gz
69+
determine-image-tag:
70+
if: contains(github.event.pull_request.labels.*.name, 'ready-to-run')
71+
runs-on: ubuntu-latest
72+
outputs:
73+
go_version: ${{ steps.get-version.outputs.go_version }}
74+
steps:
75+
- name: checkout ci repo
76+
uses: actions/checkout@v4.3.1
77+
with:
78+
repository: cloudfoundry/wg-app-platform-runtime-ci
79+
sparse-checkout: go-version.json
80+
sparse-checkout-cone-mode: false
81+
- name: get-version
82+
id: get-version
83+
run: |
84+
version=$(jq -r '.releases["cf-networking"] // .default' go-version.json)
85+
echo "go_version=${version}" >> "$GITHUB_OUTPUT"
86+
template-tests:
87+
runs-on: ubuntu-latest
88+
needs: [repo-clone]
89+
container: cloudfoundry/tas-runtime-build:latest
90+
steps:
91+
- name: Download artifact
92+
uses: actions/download-artifact@v4
93+
with:
94+
name: repo
95+
- run: |
96+
tar -xzvf repo-artifact.tar.gz
97+
tar -xzvf ci-artifact.tar.gz
98+
- name: template-tests
99+
run: |
100+
"${GITHUB_WORKSPACE}"/ci/shared/tasks/run-tests-templates/task.bash
101+
lint-repo:
102+
runs-on: ubuntu-latest
103+
needs: [repo-clone]
104+
container: cloudfoundry/tas-runtime-build:latest
105+
env:
106+
LINTERS: |
107+
sync-package-specs.bash
108+
sync-submodule-config.bash
109+
match-golang-os-package-versions.bash
110+
steps:
111+
- name: Download artifact
112+
uses: actions/download-artifact@v4
113+
with:
114+
name: repo
115+
- run: |
116+
tar -xzvf repo-artifact.tar.gz
117+
tar -xzvf ci-artifact.tar.gz
118+
- name: lint-repo
119+
run: |
120+
"${GITHUB_WORKSPACE}"/ci/shared/tasks/lint-repo/task.bash
121+
test-on-mysql-5-7:
122+
if: contains(github.event.pull_request.labels.*.name, 'ready-to-run')
123+
runs-on: ubuntu-latest
124+
needs: [repo-clone, determine-image-tag]
125+
env:
126+
BUILD_IMAGE: cloudfoundry/tas-runtime-mysql-5.7:${{ needs.determine-image-tag.outputs.go_version }}
127+
steps:
128+
- name: Download artifact
129+
uses: actions/download-artifact@v4
130+
with:
131+
name: repo
132+
- run: |
133+
tar -xzvf repo-artifact.tar.gz
134+
tar -xzvf ci-artifact.tar.gz
135+
- name: pull image
136+
run: docker pull "$BUILD_IMAGE"
137+
#@ for package in helpers.packages_with_configure_db(data.values.internal_repos):
138+
- name: #@ "{}-mysql".format(package.name)
139+
env:
140+
DIR: #@ "src/code.cloudfoundry.org/{}".format(package.name)
141+
DB: mysql
142+
run: |
143+
./repo/.github/helpers/test.bash ${{ github.workspace }} "$BUILD_IMAGE"
144+
#@ end
145+
test-repos-withoutdb:
146+
if: contains(github.event.pull_request.labels.*.name, 'ready-to-run')
147+
runs-on: ubuntu-latest
148+
needs: [repo-clone, determine-image-tag]
149+
env:
150+
BUILD_IMAGE: cloudfoundry/tas-runtime-build:${{ needs.determine-image-tag.outputs.go_version }}
151+
steps:
152+
- name: Download artifact
153+
uses: actions/download-artifact@v4
154+
with:
155+
name: repo
156+
- run: |
157+
tar -xzvf repo-artifact.tar.gz
158+
tar -xzvf ci-artifact.tar.gz
159+
- name: pull image
160+
run: docker pull "$BUILD_IMAGE"
161+
#@ for package in helpers.packages_without_configure_db(data.values.internal_repos):
162+
- name: #@ package.name
163+
env:
164+
DIR: #@ "src/code.cloudfoundry.org/{}".format(package.name)
165+
run: |
166+
export DIR=$DIR
167+
./repo/.github/helpers/test.bash ${{ github.workspace }} "$BUILD_IMAGE"
168+
#@ end
169+
test-on-postgres:
170+
if: contains(github.event.pull_request.labels.*.name, 'ready-to-run')
171+
runs-on: ubuntu-latest
172+
needs: [repo-clone, determine-image-tag]
173+
env:
174+
BUILD_IMAGE: cloudfoundry/tas-runtime-postgres:${{ needs.determine-image-tag.outputs.go_version }}
175+
steps:
176+
- name: Download artifact
177+
uses: actions/download-artifact@v4
178+
with:
179+
name: repo
180+
- run: |
181+
tar -xzvf repo-artifact.tar.gz
182+
tar -xzvf ci-artifact.tar.gz
183+
- name: pull image
184+
run: docker pull "$BUILD_IMAGE"
185+
#@ for package in helpers.packages_with_configure_db(data.values.internal_repos):
186+
- name: #@ "{}-postgres".format(package.name)
187+
env:
188+
DIR: #@ "src/code.cloudfoundry.org/{}".format(package.name)
189+
DB: postgres
190+
run: |
191+
./repo/.github/helpers/test.bash ${{ github.workspace }} "$BUILD_IMAGE"
192+
#@ end
193+
test-on-mysql-8-0:
194+
if: contains(github.event.pull_request.labels.*.name, 'ready-to-run')
195+
runs-on: ubuntu-latest
196+
needs: [repo-clone, determine-image-tag]
197+
env:
198+
BUILD_IMAGE: cloudfoundry/tas-runtime-mysql-8.0:${{ needs.determine-image-tag.outputs.go_version }}
199+
steps:
200+
- name: Download artifact
201+
uses: actions/download-artifact@v4
202+
with:
203+
name: repo
204+
- run: |
205+
tar -xzvf repo-artifact.tar.gz
206+
tar -xzvf ci-artifact.tar.gz
207+
- name: pull image
208+
run: docker pull "$BUILD_IMAGE"
209+
#@ for package in helpers.packages_with_configure_db(data.values.internal_repos):
210+
- name: #@ "{}-mysql".format(package.name)
211+
env:
212+
DIR: #@ "src/code.cloudfoundry.org/{}".format(package.name)
213+
DB: mysql
214+
run: |
215+
./repo/.github/helpers/test.bash ${{ github.workspace }} "$BUILD_IMAGE"
216+
#@ end

.github/helpers/test.bash

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
set -eu
4+
set -o pipefail
5+
GH_WORKSPACE=$1
6+
BUILD_IMAGE=$2
7+
docker run --cap-add=SYS_ADMIN --rm --privileged \
8+
-v "$GH_WORKSPACE:/workspace" \
9+
-w /workspace \
10+
-e MAPPING="$MAPPING" -e DB="$DB" -e DIR="$DIR" -e RUN_AS="$RUN_AS" -e VERIFICATIONS="$VERIFICATIONS" -e FUNCTIONS="$FUNCTIONS" \
11+
"$BUILD_IMAGE" \
12+
bash ./ci/shared/tasks/run-bin-test/task.bash --keep-going --trace -r --fail-on-pending --randomize-all --nodes=7 --race --timeout 30m --flake-attempts 2

0 commit comments

Comments
 (0)