From 47289a4d33e2d8b9482c13004290360195c09b6e Mon Sep 17 00:00:00 2001 From: erik-krogh Date: Fri, 4 Nov 2022 11:25:46 +0100 Subject: [PATCH 1/2] fix merge-base compilation when running directly on main --- .github/workflows/compile-queries.yml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/compile-queries.yml b/.github/workflows/compile-queries.yml index 8e058a8c54e7..a7fb43debf34 100644 --- a/.github/workflows/compile-queries.yml +++ b/.github/workflows/compile-queries.yml @@ -18,12 +18,18 @@ jobs: fetch-depth: 0 # calculate the merge-base with main, in a way that works both on PRs and pushes to main. - name: Calculate merge-base - id: merge-base + if: ${{ github.event_name == 'pull_request' }} env: BASE_BRANCH: ${{ github.base_ref }} run: | MERGE_BASE=$(git merge-base --fork-point origin/$BASE_BRANCH) echo "merge-base=$MERGE_BASE" >> $GITHUB_ENV + - name: Calculate merge-base - main + if: ${{ github.event_name != 'pull_request' }} + # using github.sha instead, since we're on main + run: | + MERGE_BASE=${{ github.sha }}) + echo "merge-base=$MERGE_BASE" >> $GITHUB_ENV - name: Cache CodeQL query compilation uses: actions/cache@v3 with: @@ -41,11 +47,11 @@ jobs: run: codeql query format */ql/{src,lib,test}/**/*.{qll,ql} --check-only - name: compile queries - check-only # run with --check-only if running in a PR (github.sha != main) - if : ${{ github.sha != steps.merge-base.outputs.merge-base }} + if : ${{ github.event_name == 'pull_request' }} shell: bash run: codeql query compile -j0 */ql/src --keep-going --warnings=error --check-only - name: compile queries - full # do full compile if running on main - this populates the cache - if : ${{ github.sha == steps.merge-base.outputs.merge-base }} + if : ${{ github.event_name != 'pull_request' }} shell: bash run: codeql query compile -j0 */ql/src --keep-going --warnings=error \ No newline at end of file From 91b33f72b51d9bae98d092fd38b2939d66ec628e Mon Sep 17 00:00:00 2001 From: Erik Krogh Kristensen Date: Fri, 4 Nov 2022 12:50:18 +0100 Subject: [PATCH 2/2] update name and comment to reflect that it also runs on rc branches --- .github/workflows/compile-queries.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/compile-queries.yml b/.github/workflows/compile-queries.yml index a7fb43debf34..20e5add55e72 100644 --- a/.github/workflows/compile-queries.yml +++ b/.github/workflows/compile-queries.yml @@ -24,9 +24,9 @@ jobs: run: | MERGE_BASE=$(git merge-base --fork-point origin/$BASE_BRANCH) echo "merge-base=$MERGE_BASE" >> $GITHUB_ENV - - name: Calculate merge-base - main + - name: Calculate merge-base - branch if: ${{ github.event_name != 'pull_request' }} - # using github.sha instead, since we're on main + # using github.sha instead, since we're directly on a branch, and not in a PR run: | MERGE_BASE=${{ github.sha }}) echo "merge-base=$MERGE_BASE" >> $GITHUB_ENV