CI #1883
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| release: | |
| types: [released] | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| schedule: | |
| - cron: '0 0 * * *' | |
| permissions: | |
| contents: read | |
| jobs: | |
| quality_checks: | |
| name: Quality checks | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 5 | |
| strategy: | |
| matrix: | |
| node: [18, 20, 22] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4.2.2 | |
| - name: Setup NodeJS ${{ matrix.node }} | |
| uses: actions/setup-node@v4.4.0 | |
| with: | |
| node-version: ${{ matrix.node }} | |
| cache: 'npm' | |
| - name: Install deps | |
| run: npm ci | |
| - name: Run tests | |
| run: npm test -- --coverage | |
| security_checks: | |
| name: Security checks | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 5 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4.2.2 | |
| - name: Setup NodeJS | |
| uses: actions/setup-node@v4.4.0 | |
| with: | |
| node-version: '22' | |
| cache: 'npm' | |
| - name: Audit dependencies | |
| run: npm audit --audit-level=low --production | |
| lint: | |
| name: Lint | |
| if: github.ref != 'refs/heads/main' # Don't run for main branch | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4.2.2 | |
| - name: Lint Code Base | |
| uses: github/super-linter/slim@v5 | |
| env: | |
| VALIDATE_ALL_CODEBASE: false | |
| DEFAULT_BRANCH: main | |
| VALIDATE_JAVASCRIPT_ES: true | |
| VALIDATE_JSON: true | |
| VALIDATE_YAML: true | |
| publish: | |
| name: Publish | |
| needs: [quality_checks, security_checks, lint] | |
| if: github.event_name == 'release' && github.event.action == 'released' | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 5 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4.2.2 | |
| - name: Setup NodeJS | |
| uses: actions/setup-node@v4.4.0 | |
| with: | |
| node-version: '22' | |
| cache: 'npm' | |
| registry-url: https://registry.npmjs.org | |
| scope: '@quickcase' | |
| - name: Install deps | |
| run: npm ci | |
| - name: Publish | |
| run: npm publish | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| end: | |
| name: End | |
| needs: [quality_checks, security_checks, lint, publish] | |
| if: always() | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 5 | |
| env: | |
| SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} | |
| steps: | |
| - name: Build summary | |
| id: summary | |
| env: | |
| QUALITY: ${{ needs.quality_checks.result }} | |
| SECURITY: ${{ needs.security_checks.result }} | |
| LINT: ${{ needs.lint.result }} | |
| PUBLISH: ${{ needs.publish.result }} | |
| run: | | |
| echo "success=$(if [[ "$QUALITY$SECURITY$LINT$PUBLISH" =~ ^(success|skipped)+$ ]]; then echo "true"; else echo "false"; fi)" >> $GITHUB_OUTPUT | |
| - name: Notify slack fail | |
| if: steps.summary.outputs.success != 'true' && env.SLACK_BOT_TOKEN != 0 | |
| uses: slackapi/slack-github-action@v1.27.0 | |
| with: | |
| channel-id: dev | |
| payload: | | |
| { | |
| "text": "${{github.repository}}: CI failed", | |
| "blocks": [ | |
| { | |
| "type": "header", | |
| "text": { | |
| "type": "plain_text", | |
| "emoji": true, | |
| "text": ":x: ${{github.repository}}: CI failed" | |
| } | |
| }, | |
| { | |
| "type": "context", | |
| "elements": [ | |
| { | |
| "type": "mrkdwn", | |
| "text": "Repository: <${{github.server_url}}/${{github.repository}}|${{github.repository}}>" | |
| }, | |
| { | |
| "type": "mrkdwn", | |
| "text": "Triggered by: *${{github.triggering_actor}}*" | |
| } | |
| ] | |
| }, | |
| { | |
| "type": "section", | |
| "text": { | |
| "type": "mrkdwn", | |
| "text": "See failed run: <${{github.server_url}}/${{github.repository}}/actions/runs/${{github.run_id}}|${{github.run_id}}>" | |
| } | |
| } | |
| ] | |
| } |