diff --git a/.github/workflows/postman.yml b/.github/workflows/postman.yml new file mode 100644 index 000000000..0f98fd216 --- /dev/null +++ b/.github/workflows/postman.yml @@ -0,0 +1,82 @@ +name: 'postman' +on: + pull_request: + branches: + - '*' + workflow_dispatch: +jobs: + postman: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set npm token + env: + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + echo "@linode:registry=https://npm.pkg.github.com/linode" > .npmrc + echo "//npm.pkg.github.com/:_authToken=${NODE_AUTH_TOKEN}" >> .npmrc + echo '::set-output name=diff::1' + - name: Install Node + run: | + export NVM_DIR="$HOME/.nvm" + [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" + nvm install + nvm use + node -v + npm install + - uses: actions/checkout@v4 + with: + repository: linode/apl-core + path: apl-core + - name: Create Git repo + run: | + readonly env_dir="$HOME/workspace/linode/values-ofld1" + readonly apl_core_test_fixtures="$HOME/work/apl-api/apl-api/apl-core/tests/fixtures" + mkdir -p "$(dirname $env_dir)" + cp -R $apl_core_test_fixtures $env_dir + cd $env_dir + git init + git checkout -b main + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git add . + git commit -a -m 'init' + # Mark this repo as bare so the local_env_dir can push to env_dir repo + git config --bool core.bare true + echo "The values bare repo has been successfully set up" + ls + - name: Start core server + run: | + cd apl-core + npm install + npm run server > $GITHUB_WORKSPACE/core.log 2>&1 & + - name: Start api + run: | + npm install + cp .env.sample .env + npm run dev > $GITHUB_WORKSPACE/api.log 2>&1 & + - name: Wait for api + run: | + echo "Waiting for API to be ready..." + while ! curl -s -f -o /dev/null http://localhost:8080/v2/builds; do + sleep 10 + done + echo "API is ready!" + - name: Install Postman CLI + run: | + curl -o- "https://dl-cli.pstmn.io/install/linux64.sh" | sh + - name: Login to Postman CLI + run: postman login --with-api-key ${{ secrets.POSTMAN_API_KEY }} + + - name: Run API tests + #The UUID's are the order the requests are executed in. So that the POST are executed first + run: | + postman collection run 44183872-1d1f2dba-6c47-4764-a847-a6bca216ecea -e 43715313-d380e919-5142-44e6-b52c-02f8b04da8fa -i 44183872-be57d2e3-650d-4494-ba65-6486b68082b0 -i 44183872-f50a0c10-89ef-4352-8a56-3093811b3311 -i 44183872-0a01d698-5d93-4ebf-bd52-6cd7b1af9735 -i 44183872-6229c491-250d-49a4-8388-7a2353129925 -i 44183872-07ac4c2a-037a-4002-a5d1-2e990cfcb1b0 -i 44183872-297df31a-4560-4f27-aa06-31437d59dd7c -i 44183872-47db1e8a-9245-49a6-a6ff-7044b95d8ad3 -i 44183872-beeb6115-2e7b-4a7b-bcd8-eb605a5cd3fc -i 44183872-eff09537-0ab0-4914-a15d-a08270360574 -i 44183872-5003d09d-439f-456a-8864-e6e1f62db807 -i 44183872-a25b9ea2-1c64-4bf1-a5e4-dc905f1a9a6a -i 44183872-7082300f-e721-43f3-9828-1f3bbd25ab0a -i 44183872-6631ed83-0ff4-4515-8fa6-2d57c2959e77 -i 44183872-0a483150-4d00-49f1-8f9a-31ab467f79ec -i 44183872-15ce6497-700f-49f9-949a-ec22bf169c3f -i 44183872-c4097a49-9f17-4d6e-8ff2-a1a1fcec2dff -i 44183872-e357451a-9526-4b57-bb5b-1190e0d6788f -i 44183872-9abfae13-8983-453e-85c5-a3951dddd8e6 -i 44183872-3db33396-563e-4f0a-b074-fc74680c72bd -i 44183872-61b903cb-d623-4b6d-85a3-ab2f7b0575d8 -i 44183872-34fb39a5-5bc2-4528-886a-49e4caf2d9b5 -i 44183872-e34ef3b6-f979-4407-8e69-b972be4d5184 -i 44183872-da7d9d0c-3ab1-457a-a56f-2fa49b151f1d -i 44183872-d7d08dac-364f-4f94-9c48-64dbd77fcadd -i 44183872-a6fad9da-3fae-4c7c-9e15-ec6d67a79b78 -i 44183872-79ff962a-4117-4b91-8cb6-2653b6d5a687 -i 44183872-225a21ca-9106-484c-83b5-1257bc6433e7 -i 44183872-7ac118a2-7f55-4996-a2e6-0b34eb7058ae -i 44183872-4d49d6c6-6367-4ec4-8b4c-6c6154118a3a -i 44183872-dd1b76be-26ee-4b5b-913b-8ce465778229 -i 44183872-ee200410-27ac-4c28-a469-21f487dfbaec -i 44183872-c7676daa-2257-47d6-88ca-178d433a5f28 -i 44183872-f162b5b5-1428-4f9e-8ea5-6bb3b7980b48 -i 44183872-048cddb0-5671-4abb-ac9f-8985c8e4ed6d -i 44183872-a9b4f64a-60be-43e5-bb55-6e16c85c9215 -i 44183872-a26a7e26-0df8-4ad9-95ce-ce168010f631 -i 44183872-9feaad53-dac9-475d-bd71-192d0c844e59 -i 44183872-d09732cd-0395-4b25-85c9-01b9c6a7d43c -i 44183872-1c7dca5b-58aa-4bb6-9224-d703e88b17cd -i 44183872-d183edcc-b144-4e80-9e10-72bf49f535d0 -i 44183872-7451bc15-e0cc-44a8-946b-f09bf024c9eb -i 44183872-3d6e845b-8a82-43b4-a6be-e30effc16d46 -i 44183872-d81fa269-56a3-4eef-934e-39a30e9e5dfd -i 44183872-0ed3bf3e-d78b-4818-bb47-ded64e22525f -i 44183872-fe220b54-58ce-427f-bd19-2f2716cfaa65 + - name: Upload logs + if: always() + uses: actions/upload-artifact@v4 + with: + name: server-logs + path: | + core.log + api.log diff --git a/.gitignore b/.gitignore index e23704419..db87b555f 100644 --- a/.gitignore +++ b/.gitignore @@ -50,3 +50,5 @@ secrets.*.yaml.dec .idea/ .DS_Store + +src/.DS_Store diff --git a/src/openapi/api.yaml b/src/openapi/api.yaml index 114fac75a..7f596d488 100644 --- a/src/openapi/api.yaml +++ b/src/openapi/api.yaml @@ -2602,7 +2602,6 @@ components: type: object properties: name: - example: name $ref: 'definitions.yaml#/idName' required: - name @@ -2615,12 +2614,11 @@ components: type: object properties: name: - type: string + $ref: 'definitions.yaml#/idName' labels: type: object properties: apl.io/teamId: - example: team-name $ref: 'definitions.yaml#/idName' required: - apl.io/teamId diff --git a/src/openapi/build.yaml b/src/openapi/build.yaml index 4af18fa96..8928b6042 100644 --- a/src/openapi/build.yaml +++ b/src/openapi/build.yaml @@ -118,9 +118,11 @@ buildMode: name: title: Name type: string + example: MY_ENV_VAR value: title: Value type: string + example: my-value required: - name - value diff --git a/src/openapi/codeRepo.yaml b/src/openapi/codeRepo.yaml index c237a90f9..5a58b6387 100644 --- a/src/openapi/codeRepo.yaml +++ b/src/openapi/codeRepo.yaml @@ -59,6 +59,7 @@ AplCodeRepoSpec: default: false secret: type: string + example: my-secret required: - gitService - repositoryUrl diff --git a/src/openapi/definitions.yaml b/src/openapi/definitions.yaml index 153fef188..a960ae626 100644 --- a/src/openapi/definitions.yaml +++ b/src/openapi/definitions.yaml @@ -108,6 +108,7 @@ alerts: annotation: type: string pattern: ^((.){1,253}\/)?(.){1,63}$ + example: apl.io/annotation annotations: description: Kubernetes annotations with arbitrary metadata type: array @@ -119,6 +120,7 @@ annotations: value: type: string maxLength: 32767 + example: apl-value autoscaling: type: object properties: @@ -625,6 +627,7 @@ idName: pattern: ^[a-z]([-a-z0-9]*[a-z0-9])+$ type: string x-message: a valid name that consists of lowercase letters, dashes + example: team-name image: allOf: - properties: @@ -654,6 +657,7 @@ imageTag: pattern: '[\w][\w.-]{0,127}' type: string x-message: a valid container registry image tag + example: latest imageSimple: properties: tag: @@ -951,6 +955,7 @@ repoUrl: pattern: ^(.+@)*([\w\d\.]+)(:[\d]+){0,1}/*(.*)$ type: string x-message: a valid git repo URL + example: github.com/example/repo resource: properties: cpu: @@ -1106,6 +1111,7 @@ svcPredeployed: url: pattern: ^https?:\/\/[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&\/=]*) type: string + example: https://gituhb.com/example vaultToken: title: Token type: string diff --git a/src/openapi/netpol.yaml b/src/openapi/netpol.yaml index 602f536d5..7a2304a33 100644 --- a/src/openapi/netpol.yaml +++ b/src/openapi/netpol.yaml @@ -55,10 +55,12 @@ ruleType: type: string title: Selector label name description: 'The name of the Pod selector label.' + example: app toLabelValue: type: string title: Selector label value description: 'The value of the Pod selector label.' + example: my-app mode: type: string default: AllowAll @@ -80,10 +82,12 @@ ruleType: type: string title: Selector label name description: 'The name of the Pod selector label.' + example: app fromLabelValue: type: string title: Selector label value description: 'The value of the Pod selector label.' + example: my-app required: - fromNamespace required: diff --git a/src/openapi/service.yaml b/src/openapi/service.yaml index 879c9eabe..446153c38 100644 --- a/src/openapi/service.yaml +++ b/src/openapi/service.yaml @@ -308,9 +308,11 @@ AplServiceSpec: name: title: Name type: string + example: my-header value: title: Value type: string + example: my-value required: - name - value