Skip to content

Commit 878e2b3

Browse files
Nivaldo Bondançameta-codesync[bot]
authored andcommitted
Adjust actions trying to fix recent issues
Summary: ## AI generated I've analyzed the failed run. The issue is that GitHub's **"Default Setup"** for CodeQL is automatically running on every push, including pushes to the `gh-pages` branch. This causes two problems: 1. On `gh-pages`: This branch only contains the built website and a vendored `node_modules/monaco-editor`. CodeQL tries to analyze the JavaScript but fails because there's no Action source code ("Analyze (actions)" error) and tries to build Java/Kotlin but fails because the source and Gradle wrapper are missing ("Analyze (java-kotlin)" error). 2. On `main`: Even on the `main` branch, CodeQL's "autobuild" often fails with Gradle projects that use complex structures or specific Java toolchains (like this one, which requires Java 17). Adding an explicit `codeql.yml` (switching to **"Advanced Setup"**) fixes this because: - We can exclude the `gh-pages` branch entirely, preventing useless and failing runs. - We can provide custom build steps (like `./gradlew :ktfmt:build`) to ensure CodeQL can successfully compile the project for analysis, instead of relying on the unreliable "autobuild". ___ Differential Revision: D106687399 fbshipit-source-id: 4f15286aca4bce85da45775d62433350e53726bb
1 parent 2d99e6c commit 878e2b3

3 files changed

Lines changed: 56 additions & 9 deletions

File tree

.github/workflows/build_and_test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ jobs:
2626
java-version: ${{ matrix.java }}
2727
distribution: zulu
2828
- name: Build ktfmt_idea_plugin
29-
run: ./gradlew :idea_plugin:build --stacktrace --no-daemon
29+
run: ./gradlew :idea_plugin:build --no-daemon
3030
- name: Build the Online Formatter
31-
run: ./gradlew :lambda:build --stacktrace --no-daemon
31+
run: ./gradlew :lambda:build --no-daemon
3232
- name: Build ktfmt
33-
run: ./gradlew :ktfmt:build --stacktrace --no-daemon
33+
run: ./gradlew :ktfmt:build --no-daemon

.github/workflows/codeql.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: "CodeQL"
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
jobs:
10+
analyze:
11+
name: Analyze
12+
runs-on: ubuntu-latest
13+
permissions:
14+
actions: read
15+
contents: read
16+
security-events: write
17+
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
language: [ 'java-kotlin' ]
22+
23+
steps:
24+
- name: Checkout repository
25+
uses: actions/checkout@v4
26+
27+
- name: Set up JDK 21
28+
uses: actions/setup-java@v4
29+
with:
30+
java-version: '21'
31+
distribution: 'zulu'
32+
cache: 'gradle'
33+
34+
- name: Initialize CodeQL
35+
uses: github/codeql-action/init@v3
36+
with:
37+
languages: ${{ matrix.language }}
38+
build-mode: manual
39+
40+
- name: Build with Gradle
41+
run: |
42+
./gradlew :ktfmt:build :lambda:build :idea_plugin:build --no-daemon
43+
44+
- name: Perform CodeQL Analysis
45+
uses: github/codeql-action/analyze@v3
46+
with:
47+
category: "/language:${{matrix.language}}"

.github/workflows/publish_artifacts_on_release.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
steps:
2323
- uses: actions/checkout@v4
2424
with:
25-
ref: ${{ github.events.release.tag_name || inputs.release_tag || github.ref }}
25+
ref: ${{ github.event.release.tag_name || inputs.release_tag || github.ref }}
2626

2727
- name: Publish IntelliJ plugin to JetBrains Marketplace
2828
run: ./gradlew :idea_plugin:publishPlugin --stacktrace --no-daemon
@@ -34,7 +34,7 @@ jobs:
3434
steps:
3535
- uses: actions/checkout@v4
3636
with:
37-
ref: ${{ github.events.release.tag_name || inputs.release_tag || github.ref }}
37+
ref: ${{ github.event.release.tag_name || inputs.release_tag || github.ref }}
3838

3939
- id: install-secret-key
4040
name: Install gpg secret key
@@ -62,11 +62,11 @@ jobs:
6262
steps:
6363
- uses: actions/checkout@v4
6464
with:
65-
ref: ${{ github.events.release.tag_name || inputs.release_tag || github.ref }}
65+
ref: ${{ github.event.release.tag_name || inputs.release_tag || github.ref }}
6666

6767
- name: Debug release tag
6868
run: |
69-
echo "Release tag: ${{ github.events.release.tag_name || inputs.release_tag }}"
69+
echo "Release tag: ${{ github.event.release.tag_name || inputs.release_tag }}"
7070
7171
- name: Build JAR artifacts
7272
run: ./gradlew :ktfmt:jar :ktfmt:shadowJar --stacktrace --no-daemon
@@ -77,7 +77,7 @@ jobs:
7777
- name: Upload JAR artifacts to GitHub Release
7878
uses: softprops/action-gh-release@v2
7979
with:
80-
tag_name: ${{ github.events.release.tag_name || inputs.release_tag }}
80+
tag_name: ${{ github.event.release.tag_name || inputs.release_tag }}
8181
files: |
8282
core/build/libs/ktfmt-*.jar
8383
env:
@@ -88,7 +88,7 @@ jobs:
8888
steps:
8989
- uses: actions/checkout@v4
9090
with:
91-
ref: ${{ github.events.release.tag_name || inputs.release_tag || github.ref }}
91+
ref: ${{ github.event.release.tag_name || inputs.release_tag || github.ref }}
9292

9393
- uses: actions/setup-node@v4
9494

0 commit comments

Comments
 (0)