diff --git a/.github/workflows/ui-ci.yaml b/.github/workflows/ui-ci.yaml new file mode 100644 index 00000000..fb10bd55 --- /dev/null +++ b/.github/workflows/ui-ci.yaml @@ -0,0 +1,164 @@ +name: Next.js Application CI + +on: + workflow_call: + inputs: + environment: + required: true + type: string + secrets: + AZURE_CREDENTIALS: + required: true + PAT_ACTION_CI: + required: true + +jobs: + build: + name: Build App + if: ${{ github.actor != 'dependabot[bot]' }} + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + token: ${{ secrets.PAT_ACTION_CI }} + fetch-depth: 0 + + - name: Use cache-yarn-install action + uses: Andrews-McMeel-Universal/cache-yarn-install@v1 + + - name: Lint javascript + run: yarn lint:js + + - name: Lint scss + run: yarn lint:styles + + - name: Push Linting Fixes + uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_user_name: amutechtest + commit_user_email: amu_deploy@amuniversal.com + commit_message: "[Formatter] Apply prettier changes" + + - name: Login to Azure + uses: Andrews-McMeel-Universal/cache-azure-login@v1 + with: + azureCredentials: "${{ secrets.AZURE_CREDENTIALS }}" + + - name: Use .env cache action + uses: Andrews-McMeel-Universal/get-envs@v1 + with: + azurecredentials: ${{ secrets.AZURE_CREDENTIALS }} + environment: ${{ inputs.environment }} + + - name: Use cache-next-build action + uses: Andrews-McMeel-Universal/cache-next-build@v1 + + unit-tests: + name: Unit Tests + needs: [build] + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Use cache-yarn-install action + uses: Andrews-McMeel-Universal/cache-yarn-install@v1 + + - name: Login to Azure + uses: Andrews-McMeel-Universal/cache-azure-login@v1 + with: + azureCredentials: "${{ secrets.AZURE_CREDENTIALS }}" + + - name: Use .env cache action + uses: Andrews-McMeel-Universal/get-envs@v1 + with: + azurecredentials: ${{ secrets.AZURE_CREDENTIALS }} + environment: ${{ inputs.environment }} + + - name: Use cache-next-build action + uses: Andrews-McMeel-Universal/cache-next-build@v1 + + - name: Run Jest tests + run: yarn test:unit:ci + + integration-tests: + name: Integration Tests + needs: [build] + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Use cache-yarn-install action + uses: Andrews-McMeel-Universal/cache-yarn-install@v1 + + - name: Install Playwright Browsers + run: yarn pretest:integration:ci + + - name: Login to Azure + uses: Andrews-McMeel-Universal/cache-azure-login@v1 + with: + azureCredentials: "${{ secrets.AZURE_CREDENTIALS }}" + + - name: Use .env cache action + uses: Andrews-McMeel-Universal/get-envs@v1 + with: + azurecredentials: ${{ secrets.AZURE_CREDENTIALS }} + environment: ${{ inputs.environment }} + + - name: Use cache-next-build action + uses: Andrews-McMeel-Universal/cache-next-build@v1 + + - name: Run Playwright tests + run: yarn test:integration:ci + + - uses: actions/upload-artifact@v3 + if: always() + with: + name: playwright-report + path: playwright-report/ + retention-days: 30 + + # Required status check + # Checks gzipped page sizes and application links + check-app: + name: Check Links and Size Limit + runs-on: ubuntu-latest + needs: [build] + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Login to Azure + uses: Andrews-McMeel-Universal/cache-azure-login@v1 + with: + azureCredentials: "${{ secrets.AZURE_CREDENTIALS }}" + + - name: Use .env cache action + uses: Andrews-McMeel-Universal/get-envs@v1 + with: + azurecredentials: ${{ secrets.AZURE_CREDENTIALS }} + environment: ${{ inputs.environment }} + + - name: Use cache-yarn-install action + uses: Andrews-McMeel-Universal/cache-yarn-install@v1 + + - name: Use cache-next-build action + uses: Andrews-McMeel-Universal/cache-next-build@v1 + + - name: Run Broken Link Checker + id: link-checker-report + continue-on-error: true + run: yarn test:links + + - name: Link Checker Results + if: ${{ failure() }} + run: echo "::warning ${{steps.link-checker-report.outputs.result}}" + + - uses: andresz1/size-limit-action@v1 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + # The size-limit-action tries to run a + # redundant yarn build + skip_step: build