|
| 1 | +name: "Nightly analysis of changes in standard repos" |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + schedule: |
| 6 | + - cron: '15 4 * * *' |
| 7 | + |
| 8 | +jobs: |
| 9 | + |
| 10 | + build: |
| 11 | + uses: github/codeql-ql/.github/workflows/build.yml@esbena/workflow-improvements |
| 12 | + with: |
| 13 | + os: '[ "ubuntu-latest" ]' |
| 14 | + |
| 15 | + prepare-alert-branch: |
| 16 | + runs-on: ubuntu-latest |
| 17 | + steps: |
| 18 | + - name: Checkout code-scanning alert branch |
| 19 | + uses: actions/checkout@v2 |
| 20 | + with: |
| 21 | + ref: nightly-changes-alerts |
| 22 | + |
| 23 | + - name: Checkout codeql |
| 24 | + uses: actions/checkout@v2 |
| 25 | + with: |
| 26 | + repository: github/codeql |
| 27 | + path: codeql |
| 28 | + |
| 29 | + - name: Checkout codeql-go |
| 30 | + uses: actions/checkout@v2 |
| 31 | + with: |
| 32 | + repository: github/codeql-go |
| 33 | + path: codeql-go |
| 34 | + |
| 35 | + - name: Store relevant files |
| 36 | + run: | |
| 37 | + git config --global user.name "${GITHUB_ACTOR}" |
| 38 | + git config --global user.email "${GITHUB_ACTOR}+github/codeql-ql@users.noreply.github.com" |
| 39 | +
|
| 40 | + # see repo-tests/import-repositories.sh |
| 41 | + for repo in codeql codeql-go; do |
| 42 | + git -C "$repo" rev-parse HEAD > "$repo.txt"; |
| 43 | + # remove upgrades and tests (heuristic) |
| 44 | + find "$repo" -depth -type d \( -path "*/upgrades" -o -path "*/ql/test" \) -exec rm -rf {} \; ; |
| 45 | + # only preserve files mentioned in tools/autobuild.sh |
| 46 | + find "$repo" -type f -not \( -name "*.qll" -o -name "*.ql" -o -name "*.dbscheme" -o -name qlpack.yml \) -exec rm -f {} \; ; |
| 47 | + # remove empty directories (git does not care though) |
| 48 | + find "$repo" -type d -empty -delete; |
| 49 | + git add "$repo" "$repo.txt"; |
| 50 | + git commit --allow-empty -m "Add $repo sources ($(tr -d '\n' < $repo.txt))"; |
| 51 | + done |
| 52 | +
|
| 53 | + git push |
| 54 | +
|
| 55 | + analyze: |
| 56 | + name: Analyze |
| 57 | + needs: |
| 58 | + - build |
| 59 | + - prepare-alert-branch |
| 60 | + |
| 61 | + runs-on: ubuntu-latest |
| 62 | + |
| 63 | + permissions: |
| 64 | + actions: read |
| 65 | + contents: read |
| 66 | + security-events: write |
| 67 | + |
| 68 | + steps: |
| 69 | + - name: Download pack |
| 70 | + uses: actions/download-artifact@v2 |
| 71 | + with: |
| 72 | + name: codeql-ql-pack |
| 73 | + path: ${{ runner.temp }}/codeql-ql-pack-artifact |
| 74 | + |
| 75 | + - name: Prepare pack |
| 76 | + run: | |
| 77 | + unzip "${PACK_ARTIFACT}/*.zip" -d "${PACK}" |
| 78 | + env: |
| 79 | + PACK_ARTIFACT: ${{ runner.temp }}/codeql-ql-pack-artifact |
| 80 | + PACK: ${{ runner.temp }}/pack |
| 81 | + |
| 82 | + - name: Hack codeql-action options |
| 83 | + run: | |
| 84 | + JSON=$(jq -nc --arg pack "${PACK}" '.resolve.queries=["--search-path", $pack] | .resolve.extractor=["--search-path", $pack] | .database.init=["--search-path", $pack]') |
| 85 | + echo "CODEQL_ACTION_EXTRA_OPTIONS=${JSON}" >> ${GITHUB_ENV} |
| 86 | + env: |
| 87 | + PACK: ${{ runner.temp }}/pack |
| 88 | + |
| 89 | + - name: Checkout code-scanning alert branch |
| 90 | + uses: actions/checkout@v2 |
| 91 | + with: |
| 92 | + ref: nightly-changes-alerts |
| 93 | + |
| 94 | + - name: Initialize CodeQL |
| 95 | + uses: github/codeql-action/init@esbena/ql |
| 96 | + with: |
| 97 | + languages: ql |
| 98 | + |
| 99 | + - name: Perform CodeQL Analysis |
| 100 | + uses: github/codeql-action/analyze@esbena/ql |
0 commit comments