Skip to content

Commit 4364937

Browse files
Merge pull request #365 from api-platform/chore/release
2 parents b5c944a + 4110ff3 commit 4364937

File tree

10 files changed

+152
-52
lines changed

10 files changed

+152
-52
lines changed

.github/workflows/cd.yml

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: CD
22

33
on:
44
push:
5-
branches:
6-
- main
7-
# Deploy if "deploy" label exists
5+
tags:
6+
- '*'
7+
# Deploy PR if "deploy" label exists
88
pull_request:
99
types: [ reopened, synchronize, labeled ]
1010

@@ -28,11 +28,6 @@ jobs:
2828
-
2929
name: Set up Docker Buildx
3030
uses: docker/setup-buildx-action@v3
31-
# gcloud does not work with Python 3.10 because "collections.Mappings" was removed in Python 3.10.
32-
-
33-
uses: actions/setup-python@v4
34-
with:
35-
python-version: 3.9.15
3631
-
3732
name: Auth gcloud
3833
id: auth
@@ -59,9 +54,9 @@ jobs:
5954
compose.yaml
6055
compose.prod.yaml
6156
set: |
62-
*.cache-from=type=gha,scope=${{github.ref}}
57+
*.cache-from=type=gha,scope=${{ github.ref }}
6358
*.cache-from=type=gha,scope=refs/heads/main
64-
*.cache-to=type=gha,scope=${{github.ref}},mode=max
59+
*.cache-to=type=gha,scope=${{ github.ref }},mode=max
6560
-
6661
name: Docker push
6762
run: |
@@ -70,11 +65,17 @@ jobs:
7065
docker push $KEYCLOAK_DOCKER_IMAGE
7166
-
7267
name: Docker tag and push latest
73-
if: github.event_name == 'push'
68+
if: github.event_name != 'pull_request'
7469
run: |
70+
docker tag $PHP_DOCKER_IMAGE europe-west1-docker.pkg.dev/${{ secrets.GKE_PROJECT }}/${{ secrets.GKE_PROJECT }}/php:${{ github.ref_name }}
71+
docker tag $PWA_DOCKER_IMAGE europe-west1-docker.pkg.dev/${{ secrets.GKE_PROJECT }}/${{ secrets.GKE_PROJECT }}/pwa:${{ github.ref_name }}
72+
docker tag $KEYCLOAK_DOCKER_IMAGE europe-west1-docker.pkg.dev/${{ secrets.GKE_PROJECT }}/${{ secrets.GKE_PROJECT }}/keycloak:${{ github.ref_name }}
7573
docker tag $PHP_DOCKER_IMAGE europe-west1-docker.pkg.dev/${{ secrets.GKE_PROJECT }}/${{ secrets.GKE_PROJECT }}/php:latest
7674
docker tag $PWA_DOCKER_IMAGE europe-west1-docker.pkg.dev/${{ secrets.GKE_PROJECT }}/${{ secrets.GKE_PROJECT }}/pwa:latest
7775
docker tag $KEYCLOAK_DOCKER_IMAGE europe-west1-docker.pkg.dev/${{ secrets.GKE_PROJECT }}/${{ secrets.GKE_PROJECT }}/keycloak:latest
76+
docker push europe-west1-docker.pkg.dev/${{ secrets.GKE_PROJECT }}/${{ secrets.GKE_PROJECT }}/php:${{ github.ref_name }}
77+
docker push europe-west1-docker.pkg.dev/${{ secrets.GKE_PROJECT }}/${{ secrets.GKE_PROJECT }}/pwa:${{ github.ref_name }}
78+
docker push europe-west1-docker.pkg.dev/${{ secrets.GKE_PROJECT }}/${{ secrets.GKE_PROJECT }}/keycloak:${{ github.ref_name }}
7879
docker push europe-west1-docker.pkg.dev/${{ secrets.GKE_PROJECT }}/${{ secrets.GKE_PROJECT }}/php:latest
7980
docker push europe-west1-docker.pkg.dev/${{ secrets.GKE_PROJECT }}/${{ secrets.GKE_PROJECT }}/pwa:latest
8081
docker push europe-west1-docker.pkg.dev/${{ secrets.GKE_PROJECT }}/${{ secrets.GKE_PROJECT }}/keycloak:latest

.github/workflows/check.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Deploy
1+
name: Check
22

33
on:
44
workflow_call:
@@ -18,9 +18,9 @@ jobs:
1818
-
1919
name: Checkout
2020
uses: actions/checkout@v4
21-
22-
- name: Run local k6 test
23-
uses: grafana/k6-action@v0.2.0
21+
-
22+
name: Run local k6 test
23+
uses: grafana/k6-action@v0.3.1
2424
with:
2525
filename: k6/script.js
2626
flags: --out json=results.json

.github/workflows/ci.yml

Lines changed: 103 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ jobs:
3535
compose.yaml
3636
compose.override.yaml
3737
set: |
38-
*.cache-from=type=gha,scope=${{github.ref}}
38+
*.cache-from=type=gha,scope=${{ github.ref }}
3939
*.cache-from=type=gha,scope=refs/heads/main
40-
*.cache-to=type=gha,scope=${{github.ref}},mode=max
40+
*.cache-to=type=gha,scope=${{ github.ref }},mode=max
4141
-
4242
name: Start services
4343
run: docker compose up --wait --no-build
@@ -71,9 +71,6 @@ jobs:
7171
-
7272
name: Run PHPStan
7373
run: docker compose exec -T php vendor/bin/phpstan --memory-limit=256M
74-
-
75-
name: Lint PWA
76-
run: docker compose exec -T pwa pnpm lint
7774

7875
# run e2e tests iso-prod
7976
e2e-tests:
@@ -113,10 +110,10 @@ jobs:
113110
compose.yaml
114111
compose.prod.yaml
115112
set: |
116-
*.cache-from=type=gha,scope=${{github.ref}}-e2e
117-
*.cache-from=type=gha,scope=${{github.ref}}
113+
*.cache-from=type=gha,scope=${{ github.ref }}-e2e
114+
*.cache-from=type=gha,scope=${{ github.ref }}
118115
*.cache-from=type=gha,scope=refs/heads/main
119-
*.cache-to=type=gha,scope=${{github.ref}}-e2e,mode=max
116+
*.cache-to=type=gha,scope=${{ github.ref }}-e2e,mode=max
120117
-
121118
name: Start Services
122119
run: docker compose up --wait --no-build
@@ -131,6 +128,7 @@ jobs:
131128
run: docker compose run --rm php bin/console doctrine:fixtures:load --no-interaction
132129
-
133130
name: Cache Playwright Binaries
131+
id: playwright-cache
134132
uses: actions/cache@v3
135133
with:
136134
path: ~/.cache/ms-playwright
@@ -139,15 +137,29 @@ jobs:
139137
name: Install PNPM
140138
uses: pnpm/action-setup@v2
141139
with:
142-
version: 8.6.2
140+
version: 8
141+
-
142+
name: Cache PNPM
143+
uses: actions/cache@v3
144+
with:
145+
path: ${{ env.PNPM_HOME }}
146+
key: ${{ runner.os }}-pnpm-${{ github.run_id }}
147+
restore-keys: |
148+
${{ runner.os }}-pnpm-
143149
-
144150
name: Install Dependencies
145151
working-directory: pwa
146152
run: pnpm install
147153
-
148-
name: Install Playwright Browsers
154+
name: Install Playwright Browsers with Deps
155+
if: steps.playwright-cache.outputs.cache-hit != 'true'
149156
working-directory: pwa
150157
run: pnpm exec playwright install --with-deps
158+
-
159+
name: Install Playwright Browsers
160+
if: steps.playwright-cache.outputs.cache-hit == 'true'
161+
working-directory: pwa
162+
run: pnpm exec playwright install
151163
-
152164
name: Run Playwright @read
153165
working-directory: pwa
@@ -168,14 +180,94 @@ jobs:
168180
path: pwa/test-results
169181

170182
lint:
171-
name: Docker Lint
183+
name: Lint
172184
runs-on: ubuntu-latest
173185
steps:
174186
-
175187
name: Checkout
176188
uses: actions/checkout@v4
189+
190+
# Lint Dockerfiles
177191
-
178192
name: Lint Dockerfiles
179193
uses: hadolint/[email protected]
180194
with:
181195
recursive: true
196+
197+
# Lint API
198+
-
199+
name: PHP CS Fixer Cache
200+
uses: actions/cache@v3
201+
with:
202+
path: api/.php-cs-fixer.cache
203+
key: ${{ runner.OS }}-phpcsfixer-${{ github.sha }}
204+
restore-keys: |
205+
${{ runner.OS }}-phpcsfixer-
206+
-
207+
name: Get API changed files
208+
id: api-changed-files
209+
uses: tj-actions/changed-files@v38
210+
-
211+
name: Get Extra Arguments for PHP-CS-Fixer
212+
id: phpcs-intersection
213+
run: |
214+
CHANGED_FILES=$(echo "${{ steps.changed-files.outputs.all_changed_and_modified_files }}" | tr ' ' '\n')
215+
if ! echo "${CHANGED_FILES}" | grep -qE "^api\/(\\.php-cs-fixer(\\.dist)?\\.php|composer\\.lock)$"; then EXTRA_ARGS=$(printf -- '--path-mode=intersection\n--\n%s' "${CHANGED_FILES}"); else EXTRA_ARGS=''; fi
216+
echo "PHPCS_EXTRA_ARGS<<EOF" >> $GITHUB_ENV
217+
echo "$EXTRA_ARGS" >> $GITHUB_ENV
218+
echo "EOF" >> $GITHUB_ENV
219+
-
220+
name: Lint API
221+
uses: docker://oskarstark/php-cs-fixer-ga
222+
with:
223+
args: --config=api/.php-cs-fixer.dist.php -v --dry-run --stop-on-violation --using-cache=no ${{ env.PHPCS_EXTRA_ARGS }}"
224+
225+
# Lint PWA
226+
-
227+
name: Install PNPM
228+
uses: pnpm/action-setup@v2
229+
with:
230+
version: 8
231+
-
232+
name: Cache PNPM
233+
uses: actions/cache@v3
234+
with:
235+
path: ${{ env.PNPM_HOME }}
236+
key: ${{ runner.os }}-pnpm-${{ github.run_id }}
237+
restore-keys: |
238+
${{ runner.os }}-pnpm-
239+
-
240+
name: Install Dependencies
241+
working-directory: pwa
242+
run: pnpm install
243+
-
244+
name: Lint PWA
245+
working-directory: pwa
246+
run: pnpm lint
247+
248+
# Lint HELM
249+
-
250+
name: Cache Helm Dependencies
251+
uses: actions/cache@v3
252+
with:
253+
path: helm/api-platform/charts/
254+
key: ${{ runner.os }}-helm-dependencies-${{ github.run_id }}
255+
restore-keys: |
256+
${{ runner.os }}-helm-dependencies-
257+
-
258+
name: Build Helm Dependencies
259+
run: |
260+
helm repo add bitnami https://charts.bitnami.com/bitnami/
261+
helm repo add stable https://charts.helm.sh/stable/
262+
helm dependency build ./helm/api-platform
263+
-
264+
name: Lint Helm
265+
run: helm lint ./helm/api-platform/
266+
267+
# Lint Markdown Docs
268+
-
269+
name: Lint changelog file
270+
uses: docker://avtodev/markdown-lint:v1
271+
with:
272+
config: 'docs/.markdown-lint.yaml'
273+
args: 'docs/**/*.md'

.github/workflows/cleanup.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ concurrency:
88
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
99
cancel-in-progress: true
1010

11+
env:
12+
GKE_CLUSTER: api-platform-demo
13+
GCE_ZONE: europe-west1-c
14+
1115
jobs:
1216
cleanup:
1317
name: Uninstall K8s Release for Closed Pull Request
@@ -17,11 +21,6 @@ jobs:
1721
contents: 'read'
1822
id-token: 'write'
1923
steps:
20-
# gcloud does not work with Python 3.10 because "collections.Mappings" was removed in Python 3.10.
21-
-
22-
uses: actions/setup-python@v4
23-
with:
24-
python-version: 3.9.15
2524
-
2625
name: Auth gcloud
2726
uses: google-github-actions/auth@v2
@@ -37,7 +36,7 @@ jobs:
3736
run: |
3837
gcloud components install gke-gcloud-auth-plugin
3938
gcloud --quiet auth configure-docker
40-
gcloud container clusters get-credentials api-platform-demo --zone europe-west1-c
39+
gcloud container clusters get-credentials ${{ env.GKE_CLUSTER }} --zone ${{ env.GCE_ZONE }}
4140
-
4241
name: Check for existing namespace
4342
id: k8s-namespace

.github/workflows/deploy.yml

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,6 @@ jobs:
5252
-
5353
name: Checkout
5454
uses: actions/checkout@v4
55-
# gcloud does not work with Python 3.10 because "collections.Mappings" was removed in Python 3.10.
56-
-
57-
uses: actions/setup-python@v4
58-
with:
59-
python-version: 3.9.15
6055
-
6156
name: Auth gcloud
6257
uses: google-github-actions/auth@v2
@@ -73,16 +68,20 @@ jobs:
7368
gcloud components install gke-gcloud-auth-plugin
7469
gcloud --quiet auth configure-docker
7570
gcloud container clusters get-credentials ${{ inputs.gke-cluster }} --zone ${{ inputs.gke-zone }}
76-
# https://github.com/helm/helm/issues/8036
7771
-
78-
name: Build helm dependencies
72+
name: Cache Helm Dependencies
73+
uses: actions/cache@v3
74+
with:
75+
path: helm/api-platform/charts/
76+
key: ${{ runner.os }}-helm-dependencies-${{ github.run_id }}
77+
restore-keys: |
78+
${{ runner.os }}-helm-dependencies-
79+
-
80+
name: Build Helm Dependencies
7981
run: |
8082
helm repo add bitnami https://charts.bitnami.com/bitnami/
8183
helm repo add stable https://charts.helm.sh/stable/
8284
helm dependency build ./helm/api-platform
83-
-
84-
name: Lint Helm
85-
run: helm lint ./helm/api-platform/
8685
# Release name MUST start with a letter
8786
-
8887
name: Deploy

.github/workflows/security.yml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,20 @@ jobs:
3131
-
3232
name: Checkout
3333
uses: actions/checkout@v4
34-
# gcloud does not work with Python 3.10 because "collections.Mappings" was removed in Python 3.10.
35-
-
36-
uses: actions/setup-python@v4
37-
with:
38-
python-version: 3.9.15
3934
-
4035
name: Auth gcloud
36+
id: auth
4137
uses: google-github-actions/auth@v2
4238
with:
39+
token_format: access_token
4340
credentials_json: ${{ secrets.GKE_SA_KEY }}
41+
-
42+
name: Login to GAR
43+
uses: docker/login-action@v3
44+
with:
45+
registry: europe-west1-docker.pkg.dev
46+
username: oauth2accesstoken
47+
password: ${{ steps.auth.outputs.access_token }}
4448
-
4549
name: Setup gcloud
4650
uses: google-github-actions/setup-gcloud@v1
@@ -49,8 +53,9 @@ jobs:
4953
-
5054
name: Configure gcloud
5155
run: |
56+
gcloud components install gke-gcloud-auth-plugin
5257
gcloud --quiet auth configure-docker
53-
gcloud container clusters get-credentials api-platform-demo --zone europe-west1-c
58+
gcloud container clusters get-credentials ${{ env.GKE_CLUSTER }} --zone ${{ env.GCE_ZONE }}
5459
-
5560
name: Pull Docker Image
5661
run: docker pull europe-west1-docker.pkg.dev/${{ secrets.GKE_PROJECT }}/${{ secrets.GKE_PROJECT }}/${{ matrix.image }}:latest

api/config/packages/api_platform.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
api_platform:
22
title: API Platform's demo
3-
version: 1.0.0
3+
version: 3.2.0
44
description: |
55
This is a demo application of the [API Platform](https://api-platform.com) framework.
66
[Its source code](https://github.com/api-platform/demo) includes various examples, check it out!

docs/.markdown-lint.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
MD013: false

helm/api-platform/Chart.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ type: application
1717
# This is the chart version. This version number should be incremented each time you make changes
1818
# to the chart and its templates, including the app version.
1919
# Versions are expected to follow Semantic Versioning (https://semver.org/)
20-
version: 0.1.0
20+
version: 3.2.0
2121

2222
# This is the version number of the application being deployed. This version number should be
2323
# incremented each time you make changes to the application. Versions are not expected to
2424
# follow Semantic Versioning. They should reflect the version the application is using.
25-
appVersion: 0.1.0
25+
appVersion: 3.2.0
2626

2727
dependencies:
2828
- name: postgresql

k6/test.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
#!/bin/bash
2+
23
cd $(dirname $0)
4+
35
if [ -z "$TARGET" ]; then
4-
echo "Missing TARGET=pr-xxx-demo.api-platform.com" 1>&2
6+
echo "Missing TARGET argument (e.g.: pr-123-demo.api-platform.com)" 1>&2
57
exit 1
68
fi
9+
710
docker run \
811
--name k6 \
912
--rm -i \

0 commit comments

Comments
 (0)