From 6895d750270c74f28c7ee3f7370e23451eb95d2a Mon Sep 17 00:00:00 2001 From: FleetAdmiralButter Date: Thu, 21 Sep 2023 13:19:41 +1000 Subject: [PATCH] add api and export_config workflows --- .github/workflows/api.yml | 59 +++++++++++++++++++++++++++++ .github/workflows/export_config.yml | 20 ++++++++++ .github/workflows/tide_build.yml | 3 -- 3 files changed, 79 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/api.yml create mode 100644 .github/workflows/export_config.yml diff --git a/.github/workflows/api.yml b/.github/workflows/api.yml new file mode 100644 index 0000000..6de0be5 --- /dev/null +++ b/.github/workflows/api.yml @@ -0,0 +1,59 @@ +name: api + +on: + workflow_call: + inputs: + tag: + description: SDP testing Docker image tag + type: string + required: false + default: migration + be_url: + description: The backend URL for testing + type: string + required: true + default: "https://nginx-php.pr-1581.content-vic.sdp4.sdp.vic.gov.au/" + +jobs: + api: + name: api + runs-on: biggy + container: + image: ghcr.io/dpc-sdp/bay/ci-builder:5.x + steps: + - name: Checkout code + uses: actions/checkout@v4 + # GitHub Actions does not support cloning to a custom path. + - name: Copy repo + run: | + cp -R /__w/${GITHUB_REPOSITORY#*/}/${GITHUB_REPOSITORY#*/} /app + - name: Set up Environment variables + run: | + echo 'BE_BASE_URL=${{ inputs.be_url }}' >> $GITHUB_ENV + - name: Wake test target + run: | + curl ${BE_BASE_URL} -s -S --max-time 1000 --write-out '%{http_code}' --output /dev/null; + - name: Install dependencies + run: | + npm install -g newman newman-reporter-htmlextra + apk add jq + - name: Run core Newman API tests + run: | + cd /app + if [ -e tests/newman/tide.collection.json ] + then + if [[ ${TEST_NEWMAN_DISABLE_CORE} == true ]] + then + echo "==> Core Tests are disabled by env var TEST_NEWMAN_DISABLE_CORE. Skip the test." + else + case ${CIRCLE_BRANCH} in + standby|production) + newman run tests/newman/tide.collection.json --folder default -e tests/newman/tide.environment.json --env-var "host=${BE_BASE_URL}" --env-var "branch=${GITHUB_REF_NAME}" --color on -r htmlextra --reporter-htmlextra-export ./report/tide.collection.report.html;; + *) + newman run tests/newman/tide.collection.json -e tests/newman/tide.environment.json --env-var "host=${BE_BASE_URL}" --env-var "branch=${GITHUB_REF_NAME}" --color on -r htmlextra --reporter-htmlextra-export ./report/tide.collection.report.html;; + esac + fi + else + echo "==> No Postman API test collection is found. Skip the test." + fi + \ No newline at end of file diff --git a/.github/workflows/export_config.yml b/.github/workflows/export_config.yml new file mode 100644 index 0000000..ba97704 --- /dev/null +++ b/.github/workflows/export_config.yml @@ -0,0 +1,20 @@ +name: export_config + +on: workflow_call + +jobs: + build_tide: + name: export_config + runs-on: biggy + container: + image: ghcr.io/dpc-sdp/bay/ci-builder:5.x + steps: + - name: Checkout code + uses: actions/checkout@v4 + # GitHub Actions does not support cloning to a custom path. + - name: Copy repo + run: | + cp -R /__w/${GITHUB_REPOSITORY#*/}/${GITHUB_REPOSITORY#*/} /app + - name: Run export script + run: | + /app/.circleci/export-config.sh \ No newline at end of file diff --git a/.github/workflows/tide_build.yml b/.github/workflows/tide_build.yml index 7bd2f45..6e11175 100644 --- a/.github/workflows/tide_build.yml +++ b/.github/workflows/tide_build.yml @@ -15,9 +15,6 @@ jobs: - name: Copy repo run: | cp -R /__w/${GITHUB_REPOSITORY#*/}/${GITHUB_REPOSITORY#*/} /app - - name: List /app directory - run: | - ls -a /app - name: Run build script run: | /app/.circleci/build.sh