Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci(schema): check for OpenAPI and GraphQL schema changes #334

Merged
merged 50 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
1ae99ff
move OpenAPI path to /api
andrewazores Mar 19, 2024
1dae8a6
check in initial OpenAPI and GraphQL schemas
andrewazores Mar 19, 2024
eb9398e
add CI actions to compare schemas
andrewazores Mar 19, 2024
4271ae1
only upload artifacts for JDK 17 builds
andrewazores Mar 19, 2024
1bbed70
check out repo in new steps, ensure background smoketest is cleaned up
andrewazores Mar 19, 2024
96290da
fixup! check out repo in new steps, ensure background smoketest is cl…
andrewazores Mar 19, 2024
636f0d6
use docker in schema comparisons and smoketests
andrewazores Mar 19, 2024
5871db1
don't use docker, use podman and ensure it's used fully
andrewazores Mar 19, 2024
4aedf57
correct image load tagging
andrewazores Mar 19, 2024
9f7920f
use quarkus dev instead of running full smoketest
andrewazores Mar 19, 2024
44168d9
fixup! use quarkus dev instead of running full smoketest
andrewazores Mar 19, 2024
e32ed71
skip tests and spotless checking
andrewazores Mar 19, 2024
ac48cbb
replace until with while
andrewazores Mar 19, 2024
85e9ce1
use maven wrapper, give initial time for startup before starting heal…
andrewazores Mar 19, 2024
4125f41
set up JDK 17
andrewazores Mar 19, 2024
d2d1090
prime maven cache before execution
andrewazores Mar 19, 2024
88a9721
ensure devserver can build frontend
andrewazores Mar 19, 2024
996ed31
add -B -U to mvnw
andrewazores Mar 19, 2024
13b039c
file paths
andrewazores Mar 19, 2024
d384cac
correct downloaded artifact name?
andrewazores Mar 19, 2024
5081d03
override OpenAPI title to match production build
andrewazores Mar 19, 2024
296daee
diff format
andrewazores Mar 19, 2024
97a3c39
sort yaml keys to ensure differences are not simply key ordering
andrewazores Mar 19, 2024
28237ca
use better yq action
andrewazores Mar 19, 2024
b676731
use yq direct binary, not the github action docker image
andrewazores Mar 19, 2024
f930c0b
comment about schema findings
andrewazores Mar 20, 2024
4bf2813
split output assignments
andrewazores Mar 20, 2024
33512d5
quote file path
andrewazores Mar 20, 2024
5caefc9
don't fail step if diff returns status > 0
andrewazores Mar 20, 2024
f085903
don't bail if healthchecks fail
andrewazores Mar 20, 2024
0f932c7
typo
andrewazores Mar 20, 2024
3307cb2
diff status code exit
andrewazores Mar 20, 2024
43c278b
refactor
andrewazores Mar 20, 2024
63f1d0e
debug/fixup
andrewazores Mar 20, 2024
73f5334
file path?
andrewazores Mar 20, 2024
c503baa
don't try to yaml-format the graphql schema
andrewazores Mar 20, 2024
746de5f
apply yq key sorting
andrewazores Mar 20, 2024
31e5911
do yq sorting in pipe
andrewazores Mar 20, 2024
9cdbf2f
status code fixup
andrewazores Mar 20, 2024
26be976
ensure correct pom is used
andrewazores Mar 20, 2024
66a5638
fixup! ensure correct pom is used
andrewazores Mar 20, 2024
4680fca
fix broken loop condition
andrewazores Mar 20, 2024
988b9a4
better healthcheck loop
andrewazores Mar 20, 2024
c91a3e1
better shutdown/cleanup
andrewazores Mar 20, 2024
6b025ab
replace ~ with $HOME
andrewazores Mar 20, 2024
79804b2
variable delays/sleeps
andrewazores Mar 20, 2024
5337c43
comment out graphql handling
andrewazores Mar 20, 2024
228d8f3
fixup! comment out graphql handling
andrewazores Mar 20, 2024
8a0a662
fixup! fixup! comment out graphql handling
andrewazores Mar 20, 2024
4ac602a
apply 'diff' formatting to monospace block
andrewazores Mar 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 107 additions & 0 deletions .github/workflows/pr-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -183,3 +183,110 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
status: ${{ job.status }}

update-schemas:
needs: [checkout-branch]
runs-on: ubuntu-latest
outputs:
OPENAPI_STATUS: ${{ steps.schema-update.outputs.openapi_status }}
OPENAPI_DIFF_FILE: ${{ steps.schema-update.outputs.openapi_diff_file }}
# GRAPHQL_STATUS: ${{ steps.schema-update.outputs.graphql_status }}
# GRAPHQL_DIFF_FILE: ${{ steps.schema-update.outputs.graphql_diff_file }}
steps:
- uses: actions/checkout@v3
with:
repository: ${{ needs.checkout-branch.outputs.PR_repo }}
ref: ${{ needs.checkout-branch.outputs.PR_head_ref }}
submodules: true
fetch-depth: 0
- uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: 'maven'
- run: git submodule init && git submodule update
- name: Cache yarn packages
uses: actions/cache@v3
with:
path: "./src/main/webui/.yarn/cache"
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Initialize web assets
run: |
cd src/main/webui
yarn install && yarn yarn:frzinstall
cd -
- name: Update schemas
id: schema-update
run: |
set -x
mkdir "${HOME}/bin"
wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O "${HOME}/bin/yq"
chmod +x "${HOME}/bin/yq"
export PATH="${HOME}/bin:${PATH}"
bash /home/runner/work/cryostat3/cryostat3/schema/update.bash 90 15
set +e
git diff -U10 --exit-code /home/runner/work/cryostat3/cryostat3/schema/openapi.yaml > /home/runner/work/openapi.diff
echo "openapi_status=$?" >> "$GITHUB_OUTPUT"
echo "openapi_diff_file=openapi.diff" >> "$GITHUB_OUTPUT"
# git diff -U10 --exit-code /home/runner/work/cryostat3/cryostat3/schema/schema.graphql > /home/runner/work/graphql.diff
# echo "graphql_status=$?" >> "$GITHUB_OUTPUT"
# echo "graphql_diff_file=graphql.diff" >> "$GITHUB_OUTPUT"
- uses: actions/upload-artifact@v3
with:
name: openapi-diff
path: /home/runner/work/openapi.diff
- uses: actions/upload-artifact@v3
with:
name: graphql-diff
path: /home/runner/work/graphql.diff

compare-openapi-schema:
needs: [update-schemas]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v3
with:
name: openapi-diff
- name: Comment schema check result
uses: actions/github-script@v6
with:
script: |
const diffFmt = s => {
return "```diff\n" + s + "\n```";
};
const commentBody = ${{ needs.update-schemas.outputs.OPENAPI_STATUS }} == '0'
? `No OpenAPI schema changes detected.`
: `OpenAPI schema change detected:\n\n${diffFmt(require('fs').readFileSync('${{ needs.update-schemas.outputs.OPENAPI_DIFF_FILE }}'))}`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: commentBody
});

# compare-graphql-schema:
# needs: [update-schemas]
# runs-on: ubuntu-latest
# steps:
# - uses: actions/download-artifact@v3
# with:
# name: graphql-diff
# - name: Comment schema check result
# uses: actions/github-script@v6
# with:
# script: |
# const diffFmt = s => {
# return "```diff\n" + s + "\n```";
# };
# const commentBody = ${{ needs.update-schemas.outputs.GRAPHQL_STATUS }} == '0'
# ? `No GraphQL schema changes detected.`
# : `GraphQL schema change detected:\n\n${diffFmt(require('fs').readFileSync('${{ needs.update-schemas.outputs.GRAPHQL_DIFF_FILE }}'))}`;
# github.rest.issues.createComment({
# issue_number: context.issue.number,
# owner: context.repo.owner,
# repo: context.repo.repo,
# body: commentBody
# });
Loading
Loading