mirror of
https://github.com/neondatabase/neon.git
synced 2025-12-22 21:59:59 +00:00
CI: rework and merge lint-openapi-spec and validate-compute-manifest jobs (#12575)
## Problem We have several linters that use Node.js, but they are currently set up differently, both locally and on CI. ## Summary of changes - Add Node.js to `build-tools` image - Move `compute/package.json` -> `build-tools/package.json` and add `redocly` to it `@redocly/cli` - Unify and merge into one job `lint-openapi-spec` and `validate-compute-manifest`
This commit is contained in:
committed by
GitHub
parent
0c99f16c60
commit
caca08fe78
43
.github/workflows/build_and_test.yml
vendored
43
.github/workflows/build_and_test.yml
vendored
@@ -87,22 +87,27 @@ jobs:
|
|||||||
uses: ./.github/workflows/build-build-tools-image.yml
|
uses: ./.github/workflows/build-build-tools-image.yml
|
||||||
secrets: inherit
|
secrets: inherit
|
||||||
|
|
||||||
lint-openapi-spec:
|
lint-yamls:
|
||||||
runs-on: ubuntu-22.04
|
needs: [ meta, check-permissions, build-build-tools-image ]
|
||||||
needs: [ meta, check-permissions ]
|
|
||||||
# We do need to run this in `.*-rc-pr` because of hotfixes.
|
# We do need to run this in `.*-rc-pr` because of hotfixes.
|
||||||
if: ${{ contains(fromJSON('["pr", "push-main", "storage-rc-pr", "proxy-rc-pr", "compute-rc-pr"]'), needs.meta.outputs.run-kind) }}
|
if: ${{ contains(fromJSON('["pr", "push-main", "storage-rc-pr", "proxy-rc-pr", "compute-rc-pr"]'), needs.meta.outputs.run-kind) }}
|
||||||
|
runs-on: [ self-hosted, small ]
|
||||||
|
container:
|
||||||
|
image: ${{ needs.build-build-tools-image.outputs.image }}
|
||||||
|
credentials:
|
||||||
|
username: ${{ github.actor }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
options: --init
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Harden the runner (Audit all outbound calls)
|
- name: Harden the runner (Audit all outbound calls)
|
||||||
uses: step-security/harden-runner@4d991eb9b905ef189e4c376166672c3f2f230481 # v2.11.0
|
uses: step-security/harden-runner@4d991eb9b905ef189e4c376166672c3f2f230481 # v2.11.0
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
|
|
||||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||||
- uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
|
|
||||||
with:
|
- run: make -C compute manifest-schema-validation
|
||||||
registry: ghcr.io
|
|
||||||
username: ${{ github.actor }}
|
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
- run: make lint-openapi-spec
|
- run: make lint-openapi-spec
|
||||||
|
|
||||||
check-codestyle-python:
|
check-codestyle-python:
|
||||||
@@ -217,28 +222,6 @@ jobs:
|
|||||||
build-tools-image: ${{ needs.build-build-tools-image.outputs.image }}-bookworm
|
build-tools-image: ${{ needs.build-build-tools-image.outputs.image }}-bookworm
|
||||||
secrets: inherit
|
secrets: inherit
|
||||||
|
|
||||||
validate-compute-manifest:
|
|
||||||
runs-on: ubuntu-22.04
|
|
||||||
needs: [ meta, check-permissions ]
|
|
||||||
# We do need to run this in `.*-rc-pr` because of hotfixes.
|
|
||||||
if: ${{ contains(fromJSON('["pr", "push-main", "storage-rc-pr", "proxy-rc-pr", "compute-rc-pr"]'), needs.meta.outputs.run-kind) }}
|
|
||||||
steps:
|
|
||||||
- name: Harden the runner (Audit all outbound calls)
|
|
||||||
uses: step-security/harden-runner@4d991eb9b905ef189e4c376166672c3f2f230481 # v2.11.0
|
|
||||||
with:
|
|
||||||
egress-policy: audit
|
|
||||||
|
|
||||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
|
||||||
|
|
||||||
- name: Set up Node.js
|
|
||||||
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
|
||||||
with:
|
|
||||||
node-version: '24'
|
|
||||||
|
|
||||||
- name: Validate manifest against schema
|
|
||||||
run: |
|
|
||||||
make -C compute manifest-schema-validation
|
|
||||||
|
|
||||||
build-and-test-locally:
|
build-and-test-locally:
|
||||||
needs: [ meta, build-build-tools-image ]
|
needs: [ meta, build-build-tools-image ]
|
||||||
# We do need to run this in `.*-rc-pr` because of hotfixes.
|
# We do need to run this in `.*-rc-pr` because of hotfixes.
|
||||||
|
|||||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -29,3 +29,6 @@ docker-compose/docker-compose-parallel.yml
|
|||||||
|
|
||||||
# pgindent typedef lists
|
# pgindent typedef lists
|
||||||
*.list
|
*.list
|
||||||
|
|
||||||
|
# Node
|
||||||
|
**/node_modules/
|
||||||
|
|||||||
8
Makefile
8
Makefile
@@ -220,11 +220,15 @@ neon-pgindent: postgres-v17-pg-bsd-indent neon-pg-ext-v17
|
|||||||
setup-pre-commit-hook:
|
setup-pre-commit-hook:
|
||||||
ln -s -f $(ROOT_PROJECT_DIR)/pre-commit.py .git/hooks/pre-commit
|
ln -s -f $(ROOT_PROJECT_DIR)/pre-commit.py .git/hooks/pre-commit
|
||||||
|
|
||||||
|
build-tools/node_modules: build-tools/package.json
|
||||||
|
cd build-tools && $(if $(CI),npm ci,npm install)
|
||||||
|
touch build-tools/node_modules
|
||||||
|
|
||||||
.PHONY: lint-openapi-spec
|
.PHONY: lint-openapi-spec
|
||||||
lint-openapi-spec:
|
lint-openapi-spec: build-tools/node_modules
|
||||||
# operation-2xx-response: pageserver timeline delete returns 404 on success
|
# operation-2xx-response: pageserver timeline delete returns 404 on success
|
||||||
find . -iname "openapi_spec.y*ml" -exec\
|
find . -iname "openapi_spec.y*ml" -exec\
|
||||||
docker run --rm -v ${PWD}:/spec ghcr.io/redocly/cli:1.34.4\
|
npx --prefix=build-tools/ redocly\
|
||||||
--skip-rule=operation-operationId --skip-rule=operation-summary --extends=minimal\
|
--skip-rule=operation-operationId --skip-rule=operation-summary --extends=minimal\
|
||||||
--skip-rule=no-server-example.com --skip-rule=operation-2xx-response\
|
--skip-rule=no-server-example.com --skip-rule=operation-2xx-response\
|
||||||
lint {} \+
|
lint {} \+
|
||||||
|
|||||||
@@ -188,6 +188,12 @@ RUN curl -fsSL 'https://apt.llvm.org/llvm-snapshot.gpg.key' | apt-key add - \
|
|||||||
&& bash -c 'for f in /usr/bin/clang*-${LLVM_VERSION} /usr/bin/llvm*-${LLVM_VERSION}; do ln -s "${f}" "${f%-${LLVM_VERSION}}"; done' \
|
&& bash -c 'for f in /usr/bin/clang*-${LLVM_VERSION} /usr/bin/llvm*-${LLVM_VERSION}; do ln -s "${f}" "${f%-${LLVM_VERSION}}"; done' \
|
||||||
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
||||||
|
|
||||||
|
# Install node
|
||||||
|
ENV NODE_VERSION=24
|
||||||
|
RUN curl -fsSL https://deb.nodesource.com/setup_${NODE_VERSION}.x | bash - \
|
||||||
|
&& apt install -y nodejs \
|
||||||
|
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
||||||
|
|
||||||
# Install docker
|
# Install docker
|
||||||
RUN curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg \
|
RUN curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg \
|
||||||
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian ${DEBIAN_VERSION} stable" > /etc/apt/sources.list.d/docker.list \
|
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian ${DEBIAN_VERSION} stable" > /etc/apt/sources.list.d/docker.list \
|
||||||
|
|||||||
3189
build-tools/package-lock.json
generated
Normal file
3189
build-tools/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
8
build-tools/package.json
Normal file
8
build-tools/package.json
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"name": "build-tools",
|
||||||
|
"private": true,
|
||||||
|
"devDependencies": {
|
||||||
|
"@redocly/cli": "1.34.4",
|
||||||
|
"@sourcemeta/jsonschema": "10.0.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -50,9 +50,9 @@ jsonnetfmt-format:
|
|||||||
jsonnetfmt --in-place $(jsonnet_files)
|
jsonnetfmt --in-place $(jsonnet_files)
|
||||||
|
|
||||||
.PHONY: manifest-schema-validation
|
.PHONY: manifest-schema-validation
|
||||||
manifest-schema-validation: node_modules
|
manifest-schema-validation: ../build-tools/node_modules
|
||||||
node_modules/.bin/jsonschema validate -d https://json-schema.org/draft/2020-12/schema manifest.schema.json manifest.yaml
|
npx --prefix=../build-tools/ jsonschema validate -d https://json-schema.org/draft/2020-12/schema manifest.schema.json manifest.yaml
|
||||||
|
|
||||||
node_modules: package.json
|
../build-tools/node_modules: ../build-tools/package.json
|
||||||
npm install
|
cd ../build-tools && $(if $(CI),npm ci,npm install)
|
||||||
touch node_modules
|
touch ../build-tools/node_modules
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "neon-compute",
|
|
||||||
"private": true,
|
|
||||||
"dependencies": {
|
|
||||||
"@sourcemeta/jsonschema": "9.3.4"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user