|
| 1 | +name: Build SQ-Community Build Webapp |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: |
| 5 | + - master |
| 6 | + - branch-sqs-* |
| 7 | + |
| 8 | +permissions: |
| 9 | + id-token: write # OIDC auth for vault |
| 10 | + contents: read # Checkout |
| 11 | + |
| 12 | +env: |
| 13 | + ARTIFACTORY_URL: "https://repox.jfrog.io/artifactory" |
| 14 | + ARTIFACTORY_DEPLOY_REPO: "sonarsource-private-qa" |
| 15 | + ARTIFACTORY_DEPLOY_REPO_PUBLIC: "sonarsource-public-qa" |
| 16 | + REPORTS_PATH: apps/sq-server/build/reports |
| 17 | + DEFAULT_BRANCH: ${{ github.event.repository.default_branch }} |
| 18 | + GITHUB_BRANCH: ${{ github.head_ref || github.ref_name }} |
| 19 | + |
| 20 | +concurrency: |
| 21 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 22 | + cancel-in-progress: true |
| 23 | + |
| 24 | +jobs: |
| 25 | + build: |
| 26 | + name: Build SQ-Community Build |
| 27 | + runs-on: github-ubuntu-latest-s |
| 28 | + steps: |
| 29 | + - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5 |
| 30 | + - uses: ./.github/actions/yarn-install |
| 31 | + - name: Build SQ-Community Build |
| 32 | + id: build-sq-cb |
| 33 | + shell: bash |
| 34 | + run: | |
| 35 | + yarn nx build sq-server --output-style=static |
| 36 | + - name: Upload build results |
| 37 | + if: success() |
| 38 | + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 |
| 39 | + with: |
| 40 | + name: sq-community-build |
| 41 | + path: | |
| 42 | + apps/sq-server/build/** |
| 43 | + if-no-files-found: warn |
| 44 | + |
| 45 | + lint: |
| 46 | + name: Lint SQ-Community Build |
| 47 | + runs-on: github-ubuntu-latest-s |
| 48 | + steps: |
| 49 | + - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5 |
| 50 | + - uses: ./.github/actions/yarn-install |
| 51 | + - name: Lint SQ-Community Build |
| 52 | + id: lint-sq-cb |
| 53 | + shell: bash |
| 54 | + env: |
| 55 | + NODE_OPTIONS: --max-old-space-size=4096 |
| 56 | + run: | |
| 57 | + yarn nx run-many -t lint-report -p sq-server,tag:scope:shared,tag:scope:server --output-style=static |
| 58 | + - name: Upload lint results |
| 59 | + if: success() |
| 60 | + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 |
| 61 | + with: |
| 62 | + name: sq-cb-results-scan-lint |
| 63 | + path: | |
| 64 | + **/build/reports/** |
| 65 | + !**/node_modules/** |
| 66 | + if-no-files-found: warn |
| 67 | + |
| 68 | + unit-test: |
| 69 | + name: Unit tests SQ-Community Build |
| 70 | + runs-on: github-ubuntu-latest-l |
| 71 | + steps: |
| 72 | + - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5 |
| 73 | + - uses: ./.github/actions/yarn-install |
| 74 | + - name: Unit tests SQ-Community Build |
| 75 | + id: unit-tests-sq-community-build |
| 76 | + shell: bash |
| 77 | + env: |
| 78 | + NODE_OPTIONS: --max-old-space-size=8192 |
| 79 | + SHARD_VALUE: 1 |
| 80 | + SHARD_TOTAL: 1 |
| 81 | + run: | |
| 82 | + yarn nx test-ci-shard sq-server --output-style=static |
| 83 | + - name: Upload unit test results |
| 84 | + if: success() |
| 85 | + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 |
| 86 | + with: |
| 87 | + name: sq-cb-results-scan-coverage |
| 88 | + path: | |
| 89 | + ${{ env.REPORTS_PATH }}/** |
| 90 | + if-no-files-found: warn |
| 91 | + |
| 92 | + scan: |
| 93 | + name: Scan SQ-Community Build |
| 94 | + needs: [build, lint, unit-test] |
| 95 | + runs-on: github-ubuntu-latest-s |
| 96 | + steps: |
| 97 | + - id: secrets |
| 98 | + uses: SonarSource/vault-action-wrapper@v3 |
| 99 | + with: |
| 100 | + secrets: | |
| 101 | + development/kv/data/next url | NEXT_URL; |
| 102 | + development/kv/data/next token | NEXT_TOKEN; |
| 103 | + - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5 |
| 104 | + with: |
| 105 | + # Disabling shallow clones is recommended for improving the relevance of reporting |
| 106 | + fetch-depth: 0 |
| 107 | + - uses: ./.github/actions/yarn-install |
| 108 | + - name: Download coverage and lint reports |
| 109 | + uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5 |
| 110 | + with: |
| 111 | + pattern: sq-cb-results-scan-* |
| 112 | + path: build/reports/ |
| 113 | + merge-multiple: true |
| 114 | + - name: Scan SQ-Community Build on Next |
| 115 | + shell: bash |
| 116 | + env: |
| 117 | + SONAR_HOST_URL: ${{ fromJSON(steps.secrets.outputs.vault).NEXT_URL }} |
| 118 | + SONAR_TOKEN: ${{ fromJSON(steps.secrets.outputs.vault).NEXT_TOKEN }} |
| 119 | + run: | |
| 120 | + ls -la build/reports/ |
| 121 | + .github/scripts/scan-sq-cb.sh |
| 122 | +
|
| 123 | + slack-notifications: |
| 124 | + runs-on: github-ubuntu-latest-s # Public GH runner is required, runners starting with sonar-* do not support this action |
| 125 | + if: failure() && github.ref_name == 'master' |
| 126 | + needs: [build, scan] |
| 127 | + permissions: |
| 128 | + id-token: write |
| 129 | + steps: |
| 130 | + - name: Vault Secrets |
| 131 | + id: secrets |
| 132 | + uses: SonarSource/vault-action-wrapper@v3 |
| 133 | + with: |
| 134 | + secrets: | |
| 135 | + development/kv/data/slack token | SLACK_TOKEN; |
| 136 | +
|
| 137 | + - name: Slack Notification rtCamp |
| 138 | + uses: rtCamp/action-slack-notify@e31e87e03dd19038e411e38ae27cbad084a90661 # v2.3.3 |
| 139 | + env: |
| 140 | + SLACK_TOKEN: ${{ fromJSON(steps.secrets.outputs.vault).SLACK_TOKEN }} |
| 141 | + SLACK_CHANNEL: ops-sonarqube-webapp |
| 142 | + SLACK_TITLE: SQ-Community Build failed 🚨 |
| 143 | + SLACK_ICON_EMOJI: ":github:" |
| 144 | + SLACK_USERNAME: BuildBot |
| 145 | + SLACK_COLOR: danger |
| 146 | + SLACK_MESSAGE: | |
| 147 | + Workflow failed in ${{ github.repository }} |
| 148 | + ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} |
| 149 | + Branch: ${{ github.head_ref || github.ref_name }} |
0 commit comments