Skip to content

Commit db3f4bf

Browse files
authored
fix Dockerfile for openapi check & add validator workflow (#58261)
1 parent 48aaa70 commit db3f4bf

File tree

2 files changed

+51
-4
lines changed

2 files changed

+51
-4
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Validate OpenAPI Check Docker
2+
3+
# **What it does**: Tests building and running the OpenAPI check Docker container
4+
# **Why we have it**: To ensure the Dockerfile and openapi-check script work correctly
5+
# **Who does it impact**: Docs engineering.
6+
7+
on:
8+
workflow_dispatch:
9+
pull_request:
10+
paths:
11+
- 'Dockerfile.openapi_decorator'
12+
- 'src/rest/scripts/openapi-check.ts'
13+
- 'src/rest/scripts/utils/get-operations.ts'
14+
- 'src/rest/scripts/utils/operation.ts'
15+
# In case dependencies change
16+
- 'package.json'
17+
- 'package-lock.json'
18+
- 'tsconfig.json'
19+
# Self-test
20+
- '.github/workflows/validate-openapi-check.yml'
21+
22+
permissions:
23+
contents: read
24+
25+
jobs:
26+
validate-openapi-check:
27+
runs-on: ubuntu-latest
28+
if: github.repository == 'github/docs-internal'
29+
steps:
30+
- name: Checkout
31+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
32+
33+
- name: Set up Docker Buildx
34+
uses: docker/setup-buildx-action@c47758b77c9736f4b2ef4073d4d51994fabfe349 # v3.7.1
35+
36+
- name: Build Docker image
37+
run: |
38+
docker build -f Dockerfile.openapi_decorator -t openapi-decorator:test .
39+
40+
- name: Test Docker image with sample OpenAPI file
41+
run: |
42+
docker run --rm openapi-decorator:test -f "src/rest/data/fpt-2022-11-28/schema.json"
43+
44+
- name: Test Docker image with multiple OpenAPI files
45+
run: |
46+
docker run --rm openapi-decorator:test \
47+
-f "src/rest/data/fpt-2022-11-28/schema.json" \
48+
"src/rest/data/ghec-2022-11-28/schema.json"

Dockerfile.openapi_decorator

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
FROM node:18.15-alpine
2-
3-
RUN apk add --no-cache git python make g++
1+
FROM node:24-alpine
42

53
WORKDIR /openapi-check
64

@@ -10,10 +8,11 @@ USER node
108

119
COPY --chown=node:node package.json /openapi-check
1210
COPY --chown=node:node package-lock.json /openapi-check
11+
COPY --chown=node:node tsconfig.json /openapi-check
1312
ADD --chown=node:node src /openapi-check/src
1413
ADD --chown=node:node content /openapi-check/content
1514
ADD --chown=node:node data /openapi-check/data
1615

1716
RUN npm ci -D
1817

19-
ENTRYPOINT ["node", "/openapi-check/src/rest/scripts/openapi-check.ts"]
18+
ENTRYPOINT ["npx", "tsx", "/openapi-check/src/rest/scripts/openapi-check.ts"]

0 commit comments

Comments
 (0)