diff --git a/.github/codeql/codeql-config.yml b/.github/codeql/codeql-config.yml new file mode 100644 index 000000000..3c517b871 --- /dev/null +++ b/.github/codeql/codeql-config.yml @@ -0,0 +1,7 @@ +name: "CodeQL" + +languages: + - java-kotlin + +queries: + - uses: security-and-quality diff --git a/.github/dependency-review-config.yml b/.github/dependency-review-config.yml new file mode 100644 index 000000000..882c0c157 --- /dev/null +++ b/.github/dependency-review-config.yml @@ -0,0 +1,11 @@ +license-check: true +vulnerability-check: true +fail-on-severity: "high" + +allow-ghsas: + - GHSA-22wj-vf5f-wrvj # build-time only (com.h2database:h2) + - GHSA-4265-ccf5-phj5 # build-time only (org.apache.commons:commons-compress) + - GHSA-7g45-4rm6-3mm3 # build-time only (com.google.guava:guava) + - GHSA-5mg8-w23w-74h3 # build-time only (com.google.guava:guava) + - GHSA-hr8g-6v94-x4m9 # build-time only (org.bouncycastle:bcprov-*) + - GHSA-wjxj-5m7g-mg7q # build-time only (org.bouncycastle:bcp*) diff --git a/.github/workflows/checks.apicheck.yml b/.github/workflows/checks.apicheck.yml new file mode 100644 index 000000000..3b54b3959 --- /dev/null +++ b/.github/workflows/checks.apicheck.yml @@ -0,0 +1,76 @@ +name: "API Check" + +"on": + workflow_dispatch: {} + workflow_call: + inputs: + ignore_failures: + description: "Ignore failures" + required: false + type: boolean + default: false + + secrets: + GRADLE_CONFIGURATION_KEY: + description: "Gradle cache key" + required: false + BUILDLESS_APIKEY: + description: "Buildless key" + required: false + +permissions: + contents: "read" + +jobs: + api-check: + name: "API Check" + runs-on: ubuntu-latest + continue-on-error: true + steps: + - name: "Setup: Harden Runner" + uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0 + with: + egress-policy: audit + - name: "Setup: Checkout" + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + fetch-depth: 0 + persist-credentials: false + - name: "Setup: Cache Restore (Build)" + id: cache-restore-build + uses: actions/cache/restore@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0 + with: + key: pkl-v1-build-${{ hashFiles('gradle/libs.versions.toml') }} + restore-keys: | + pkl-v1-build-${{ hashFiles('gradle/libs.versions.toml') }} + pkl-v1-build- + pkl-v1- + pkl- + path: | + .gradle/ + build/ + .codebase/ + .kotlin/ + ./*/build/bin + ./*/build/classes + ./*/build/kotlin + ./*/build/klib + ./*/build/generated + ./*/build/generated-sources + - name: "Setup: Java 21" + uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 # v4.0.0 + with: + distribution: 'adopt' + java-version: '21' + - name: "Analysis: API Check" + uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0 + continue-on-error: ${{ inputs.ignore_failures }} + env: + CI: true + with: + cache-read-only: true + cache-encryption-key: ${{ secrets.GRADLE_CONFIGURATION_KEY }} + arguments: | + apiCheck + -x test + -PenableAnalysis=true diff --git a/.github/workflows/checks.codeql.yml b/.github/workflows/checks.codeql.yml new file mode 100644 index 000000000..2c979838f --- /dev/null +++ b/.github/workflows/checks.codeql.yml @@ -0,0 +1,95 @@ +name: "CodeQL" + +"on": + workflow_dispatch: {} + workflow_call: + inputs: {} + secrets: + GRADLE_CONFIGURATION_KEY: + description: "Gradle cache key" + required: false + BUILDLESS_APIKEY: + description: "Buildless key" + required: false + + schedule: + - cron: "0 0-23/2 * * *" + + push: + branches: + - main + +permissions: + contents: read + +jobs: + analyze: + name: CodeQL + runs-on: ubuntu-latest + continue-on-error: true + permissions: + actions: read + contents: read + security-events: write + strategy: + fail-fast: false + matrix: + language: ["java-kotlin"] + steps: + - name: "Setup: Harden Runner" + uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0 + with: + egress-policy: audit + - name: "Setup: Checkout" + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + persist-credentials: false + - name: "Setup: Cache Restore (Build)" + id: cache-restore-build + uses: actions/cache/restore@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0 + with: + key: pkl-v1-build-${{ hashFiles('gradle/libs.versions.toml') }} + restore-keys: | + pkl-v1-build-${{ hashFiles('gradle/libs.versions.toml') }} + pkl-v1-build- + pkl-v1- + pkl- + path: | + .gradle/ + build/ + .codebase/ + .kotlin/ + ./*/build/bin + ./*/build/classes + ./*/build/kotlin + ./*/build/klib + ./*/build/generated + ./*/build/generated-sources + - name: "Setup: Java 21" + uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 # v4.0.0 + with: + distribution: 'adopt' + java-version: '21' + - name: "Setup: Initialize CodeQL" + uses: github/codeql-action/init@379614612a29c9e28f31f39a59013eb8012a51f0 # v3.24.3 + with: + config-file: ./.github/codeql/codeql-config.yml + languages: ${{ matrix.language }} + - name: "Analysis: Build" + uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0 + continue-on-error: true + env: + CI: true + BUILDLESS_APIKEY: ${{ secrets.BUILDLESS_APIKEY }} + with: + cache-read-only: true + cache-encryption-key: ${{ secrets.GRADLE_CONFIGURATION_KEY }} + arguments: | + compileKotlin + compileJava + assemble + -x test + -x check + - name: "Analysis: CodeQL" + uses: github/codeql-action/analyze@379614612a29c9e28f31f39a59013eb8012a51f0 # v3.24.3 + continue-on-error: true diff --git a/.github/workflows/checks.dependency-review.yml b/.github/workflows/checks.dependency-review.yml new file mode 100644 index 000000000..7abd41119 --- /dev/null +++ b/.github/workflows/checks.dependency-review.yml @@ -0,0 +1,33 @@ +name: "Dependencies" + +"on": + workflow_dispatch: {} + workflow_call: {} + +permissions: + contents: read + +jobs: + dep-review: + name: "Dependency Review" + runs-on: ubuntu-latest + steps: + - name: "Setup: Harden Runner" + uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0 + with: + egress-policy: audit + - name: "Setup: Checkout" + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + fetch-depth: 0 + persist-credentials: false + - name: "Check: Dependency Review" + uses: actions/dependency-review-action@80f10bf419f34980065523f5efca7ebed17576aa # v4.1.0 + continue-on-error: true + if: github.event_name == 'pull_request' + with: + config-file: "./.github/dependency-review-config.yml" + license-check: true + vulnerability-check: true + fail-on-severity: "low" + base-ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref || 'main' }} diff --git a/.github/workflows/checks.detekt.yml b/.github/workflows/checks.detekt.yml new file mode 100644 index 000000000..3e6b6b6cf --- /dev/null +++ b/.github/workflows/checks.detekt.yml @@ -0,0 +1,73 @@ +name: "Detekt" + +"on": + workflow_dispatch: {} + workflow_call: + inputs: {} + secrets: + GRADLE_CONFIGURATION_KEY: + description: "Gradle cache key" + required: false + BUILDLESS_APIKEY: + description: "Buildless key" + required: false + +permissions: + contents: "read" + +jobs: + sonar: + name: "Detekt" + runs-on: ubuntu-latest + continue-on-error: true + steps: + - name: "Setup: Harden Runner" + uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0 + with: + egress-policy: audit + - name: "Setup: Checkout" + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + fetch-depth: 0 + persist-credentials: false + - name: "Setup: Cache Restore (Build)" + id: cache-restore-build + uses: actions/cache/restore@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0 + with: + key: pkl-v1-build-${{ hashFiles('gradle/libs.versions.toml') }} + restore-keys: | + pkl-v1-build-${{ hashFiles('gradle/libs.versions.toml') }} + pkl-v1-build- + pkl-v1- + pkl- + path: | + .gradle/ + build/ + .codebase/ + .kotlin/ + ./*/build/bin + ./*/build/classes + ./*/build/kotlin + ./*/build/klib + ./*/build/generated + ./*/build/generated-sources + - name: "Setup: Java 21" + uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 # v4.0.0 + with: + distribution: 'adopt' + java-version: '21' + - name: "Setup: Git History" + run: git fetch --unshallow || exit 0 + - name: "Analysis: Detekt" + uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0 + continue-on-error: true + env: + CI: true + with: + cache-read-only: true + cache-encryption-key: ${{ secrets.GRADLE_CONFIGURATION_KEY }} + arguments: detekt detektMergeSarif detektMergeXml -PenableAnalysis=true -PsarifReporting=true + - name: "Report: SARIF Upload" + uses: github/codeql-action/upload-sarif@379614612a29c9e28f31f39a59013eb8012a51f0 # v3.24.3 + with: + sarif_file: build/reports/detekt/detekt.sarif diff --git a/.github/workflows/checks.formatting.yml b/.github/workflows/checks.formatting.yml new file mode 100644 index 000000000..e109285b3 --- /dev/null +++ b/.github/workflows/checks.formatting.yml @@ -0,0 +1,84 @@ +name: "Formatting" + +"on": + workflow_dispatch: + inputs: + ## Input: Ignore Failures + ignore_failures: + description: "Ignore failures" + required: false + type: boolean + default: false + + workflow_call: + inputs: + ignore_failures: + description: "Ignore failures" + required: false + type: boolean + default: false + + secrets: + GRADLE_CONFIGURATION_KEY: + description: "Gradle cache key" + required: false + BUILDLESS_APIKEY: + description: "Buildless key" + required: false + +permissions: + contents: "read" + +jobs: + fmt-check: + name: "Formatting" + runs-on: ubuntu-latest + continue-on-error: true + steps: + - name: "Setup: Harden Runner" + uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0 + with: + egress-policy: audit + - name: "Setup: Checkout" + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + fetch-depth: 0 + persist-credentials: false + - name: "Setup: Cache Restore (Build)" + id: cache-restore-build + uses: actions/cache/restore@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0 + with: + key: pkl-v1-build-${{ hashFiles('gradle/libs.versions.toml') }} + restore-keys: | + pkl-v1-build-${{ hashFiles('gradle/libs.versions.toml') }} + pkl-v1-build- + pkl-v1- + pkl- + path: | + .gradle/ + build/ + .codebase/ + .kotlin/ + ./*/build/bin + ./*/build/classes + ./*/build/kotlin + ./*/build/klib + ./*/build/generated + ./*/build/generated-sources + - name: "Setup: Java 21" + uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 # v4.0.0 + with: + distribution: 'adopt' + java-version: '21' + - name: "Analysis: Formatting (Spotless)" + uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0 + continue-on-error: ${{ inputs.ignore_failures }} + env: + CI: true + with: + cache-read-only: true + cache-encryption-key: ${{ secrets.GRADLE_CONFIGURATION_KEY }} + arguments: | + spotlessCheck + -PenableAnalysis=true + -x spotlessKotlinGradleCheck diff --git a/.github/workflows/checks.gradle-wrapper.yml b/.github/workflows/checks.gradle-wrapper.yml new file mode 100644 index 000000000..33e9ded32 --- /dev/null +++ b/.github/workflows/checks.gradle-wrapper.yml @@ -0,0 +1,25 @@ +name: "Gradle Wrapper" + +"on": + workflow_dispatch: {} + workflow_call: {} + +permissions: + contents: read + +jobs: + validation: + name: "Gradle Wrapper" + runs-on: ubuntu-latest + steps: + - name: "Setup: Harden Runner" + uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0 + with: + egress-policy: audit + - name: "Setup: Checkout" + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + fetch-depth: 0 + persist-credentials: false + - name: "Check: Gradle Wrapper" + uses: gradle/wrapper-validation-action@699bb18358f12c5b78b37bb0111d3a0e2276e0e2 # v2.1.1 diff --git a/.github/workflows/checks.scorecards.yml b/.github/workflows/checks.scorecards.yml new file mode 100644 index 000000000..8be190998 --- /dev/null +++ b/.github/workflows/checks.scorecards.yml @@ -0,0 +1,62 @@ +name: "Scorecard" + +"on": + branch_protection_rule: {} + workflow_dispatch: {} + workflow_call: {} + +# Declare default permissions as read-only. +permissions: read-all + +jobs: + analysis: + name: Scorecard analysis + runs-on: ubuntu-latest + permissions: + # Needed to upload the results to code-scanning dashboard. + security-events: write + # Needed to publish results and get a badge (see publish_results below). + id-token: write + contents: read + actions: read + steps: + - name: "Setup: Harden Runner" + uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0 + with: + egress-policy: audit + - name: "Setup: Checkout" + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + persist-credentials: false + - name: "Analysis: Scorecard" + uses: ossf/scorecard-action@0864cf19026789058feabb7e87baa5f140aac736 # v2.3.1 + with: + results_file: results.sarif + results_format: sarif + # (Optional) "write" PAT token. Uncomment the `repo_token` line below if: + # - you want to enable the Branch-Protection check on a *public* repository, or + # - you are installing Scorecards on a *private* repository + # To create the PAT, follow the steps in https://github.com/ossf/scorecard-action#authentication-with-pat. + # repo_token: ${{ secrets.SCORECARD_TOKEN }} + + # Public repositories: + # - Publish results to OpenSSF REST API for easy access by consumers + # - Allows the repository to include the Scorecard badge. + # - See https://github.com/ossf/scorecard-action#publishing-results. + # For private repositories: + # - `publish_results` will always be set to `false`, regardless + # of the value entered here. + publish_results: true + # Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF + # format to the repository Actions tab. + - name: "Artifact: Scorecard Analysis" + uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 + with: + name: SARIF file + path: results.sarif + retention-days: 5 + # Upload the results to GitHub's code scanning dashboard. + - name: "Artifact: Scorecard SARIF" + uses: github/codeql-action/upload-sarif@379614612a29c9e28f31f39a59013eb8012a51f0 # v3.24.3 + with: + sarif_file: results.sarif diff --git a/.github/workflows/job.build.yml b/.github/workflows/job.build.yml new file mode 100644 index 000000000..64b1d6437 --- /dev/null +++ b/.github/workflows/job.build.yml @@ -0,0 +1,104 @@ +name: "Build" + +"on": + workflow_dispatch: {} + workflow_call: + inputs: {} + secrets: + GRADLE_CONFIGURATION_KEY: + description: "Gradle cache key" + required: false + BUILDLESS_APIKEY: + description: "Buildless key" + required: false + +permissions: + contents: read + +jobs: + ## + ## Job: Build + ## + gradle: + name: "Build (Ubuntu)" + runs-on: ubuntu-latest + + defaults: + run: + shell: bash + + outputs: + hashes: ${{ steps.hash.outputs.hashes }} + + steps: + - name: "Setup: Harden Runner" + uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0 + with: + egress-policy: audit + - name: "Setup: Checkout" + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + submodules: true + persist-credentials: false + - name: "Setup: Cache Restore (Build)" + id: cache-restore-build + uses: actions/cache/restore@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0 + with: + key: pkl-v1-build-${{ hashFiles('gradle/libs.versions.toml') }} + restore-keys: | + pkl-v1-build-${{ hashFiles('gradle/libs.versions.toml') }} + pkl-v1-build- + pkl-v1- + pkl- + path: | + .gradle/ + build/ + .codebase/ + .kotlin/ + ./*/build/bin + ./*/build/classes + ./*/build/kotlin + ./*/build/klib + ./*/build/generated + ./*/build/generated-sources + - name: "Setup: Java 21" + uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 # v4.0.0 + with: + distribution: 'adopt' + java-version: '21' + - name: "Setup: GraalVM (Java 21)" + uses: graalvm/setup-graalvm@d72e3dbf5f44eb0b78c4f8ec61a262d8bf9b94af # v1.1.7 + with: + distribution: "graalvm" + java-version: 21 + check-for-updates: false + github-token: ${{ secrets.GITHUB_TOKEN }} + set-java-home: 'false' + - name: "🛠️ Build" + uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0 + id: gradlebuild + env: + CI: true + with: + cache-read-only: true + cache-encryption-key: ${{ secrets.GRADLE_CONFIGURATION_KEY }} + gradle-home-cache-cleanup: true + arguments: build -x test -x check --scan + build-scan-publish: true + build-scan-terms-of-service-url: "https://gradle.com/terms-of-service" + build-scan-terms-of-service-agree: "yes" + - name: "Artifact: Caches" + uses: actions/cache/save@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0 + with: + key: ${{ steps.cache-restore.outputs.cache-primary-key }} + path: | + .gradle/ + build/ + .codebase/ + .kotlin/ + ./*/build/bin + ./*/build/classes + ./*/build/kotlin + ./*/build/klib + ./*/build/generated + ./*/build/generated-sources diff --git a/.github/workflows/job.dependency-graph.yml b/.github/workflows/job.dependency-graph.yml new file mode 100644 index 000000000..4e3206f07 --- /dev/null +++ b/.github/workflows/job.dependency-graph.yml @@ -0,0 +1,75 @@ +name: "Dependency Graph" + +"on": + workflow_dispatch: {} + workflow_call: + inputs: {} + secrets: + GRADLE_CONFIGURATION_KEY: + description: "Gradle cache key" + required: false + BUILDLESS_APIKEY: + description: "Buildless key" + required: false + +permissions: + contents: read + +jobs: + ## + ## Job: Build+Submit Dependency Graph + ## + gradle: + name: "Dependency Graph" + runs-on: "ubuntu-latest" + + permissions: + ## Needed for submission of dependency graphs + contents: "write" + + defaults: + run: + shell: bash + + outputs: + hashes: ${{ steps.hash.outputs.hashes }} + + steps: + - name: "Setup: Harden Runner" + uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0 + with: + egress-policy: audit + - name: "Setup: Checkout" + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + submodules: true + persist-credentials: false + - name: "Setup: Cache Restore (Build)" + id: cache-restore-build + uses: actions/cache/restore@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0 + with: + key: pkl-v1-build-${{ hashFiles('gradle/libs.versions.toml') }} + restore-keys: | + pkl-v1-build-${{ hashFiles('gradle/libs.versions.toml') }} + pkl-v1-build- + pkl-v1- + pkl- + path: | + .gradle/ + build/ + .codebase/ + .kotlin/ + ./*/build/bin + ./*/build/classes + ./*/build/kotlin + ./*/build/klib + ./*/build/generated + ./*/build/generated-sources + - name: "Setup: Java 21" + uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 # v4.0.0 + with: + distribution: 'adopt' + java-version: '21' + - name: "🛠️ Dependency Graph" + uses: gradle/actions/dependency-submission@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0 + continue-on-error: true diff --git a/.github/workflows/job.native-build.yml b/.github/workflows/job.native-build.yml new file mode 100644 index 000000000..b4ccc6d6e --- /dev/null +++ b/.github/workflows/job.native-build.yml @@ -0,0 +1,200 @@ +name: "Native Build" + +"on": + workflow_dispatch: + inputs: + release: + type: boolean + default: false + description: "Release build" + macos: + type: boolean + default: true + description: "macOS" + linux: + type: boolean + default: true + description: "Linux" + windows: + type: boolean + default: false + description: "Windows" + artifact: + type: string + default: "" + description: "Artifact prefix" + + workflow_call: + inputs: + release: + type: boolean + default: false + description: "Release build" + macos: + type: boolean + default: true + description: "macOS" + linux: + type: boolean + default: true + description: "Linux" + windows: + type: boolean + default: false + description: "Windows" + artifact: + type: string + default: "" + description: "Artifact prefix" + + secrets: + GRADLE_CONFIGURATION_KEY: + description: "Gradle cache key" + required: false + BUILDLESS_APIKEY: + description: "Buildless key" + required: false + +permissions: + contents: read + +jobs: + ## + ## Job: Build+Submit Dependency Graph + ## + gradle: + strategy: + fail-fast: false + matrix: + os: [Ubuntu] + mode: ["Strict"] + tag: ["linux-amd64-${{ fromJson(inputs.release) && 'opt' || 'dev' }}"] + machine: ["ubuntu-latest"] + target: [":pkl-cli:linuxExecutableAmd64"] + enabled: + - ${{ fromJson(inputs.linux) }} + include: + - os: macOS x64 + tag: macos-x64-${{ fromJson(inputs.release) && 'opt' || 'dev' }} + machine: macos-13 + target: :pkl-cli:macExecutableAmd64 + enabled: ${{ fromJson(inputs.macos) }} + - os: macOS aarch64 + tag: macos-aarch64-${{ fromJson(inputs.release) && 'opt' || 'dev' }} + machine: macos-13-xlarge + target: :pkl-cli:macExecutableAarch64 + enabled: ${{ fromJson(inputs.macos) }} + + # Windows build is currently broken. + # + # - os: Windows + # machine: windows-latest + # target: :pkl-cli:windowsAmd64 + # tag: windows-x64 + + name: "Native CLI (${{ matrix.os }})" + runs-on: ${{ matrix.machine }} + + defaults: + run: + shell: bash + + outputs: + hashes: ${{ steps.hash.outputs.hashes }} + + steps: + - name: "Setup: Harden Runner" + uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0 + with: + egress-policy: audit + - name: "Setup: Checkout" + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + if: ${{ matrix.enabled }} + with: + submodules: true + persist-credentials: false + - name: "Setup: Cache Restore (Build)" + id: cache-restore-build + uses: actions/cache/restore@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0 + if: ${{ matrix.enabled }} + with: + key: pkl-v1-build-${{ hashFiles('gradle/libs.versions.toml') }} + restore-keys: | + pkl-v1-build-${{ hashFiles('gradle/libs.versions.toml') }} + pkl-v1-build- + pkl-v1- + pkl- + path: | + .gradle/ + build/ + .codebase/ + .kotlin/ + ./*/build/bin + ./*/build/classes + ./*/build/kotlin + ./*/build/klib + ./*/build/generated + ./*/build/generated-sources + - name: "Setup: Java 21" + uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 # v4.0.0 + if: ${{ matrix.enabled }} + with: + distribution: 'adopt' + java-version: '21' + - name: "Setup: GraalVM (Java 21)" + uses: graalvm/setup-graalvm@d72e3dbf5f44eb0b78c4f8ec61a262d8bf9b94af # v1.1.7 + if: ${{ matrix.enabled }} + with: + distribution: "graalvm" + java-version: 21 + check-for-updates: false + github-token: ${{ secrets.GITHUB_TOKEN }} + set-java-home: 'false' + native-image-job-reports: 'true' + - name: "🛠️ Build" + uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0 + id: gradlebuild + if: ${{ matrix.enabled }} + env: + CI: true + with: + build-scan-publish: true + build-scan-terms-of-service-url: "https://gradle.com/terms-of-service" + build-scan-terms-of-service-agree: "yes" + cache-read-only: true + cache-encryption-key: ${{ secrets.GRADLE_CONFIGURATION_KEY }} + gradle-home-cache-cleanup: true + arguments: | + assemble + build + ${{ matrix.target || ':pkl-cli:assembleNative' }} + -PnativeRelease=${{ inputs.release }} + --scan + -x test + -x check + - name: "Artifact: Native CLI" + uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 + if: ${{ matrix.enabled }} + with: + name: "${{ inputs.artifact || 'pkl-cli-latest' }}-${{ matrix.tag }}" + path: ./pkl-cli/build/distributions/pkl*.* + if-no-files-found: warn + retention-days: 14 + compression-level: 1 + overwrite: true + - name: "Artifact: Caches" + uses: actions/cache/save@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0 + if: ${{ matrix.enabled }} + with: + key: ${{ steps.cache-restore.outputs.cache-primary-key }} + path: | + .gradle/ + build/ + .codebase/ + .kotlin/ + ./*/build/bin + ./*/build/classes + ./*/build/kotlin + ./*/build/klib + ./*/build/generated + ./*/build/generated-sources diff --git a/.github/workflows/job.tests.yml b/.github/workflows/job.tests.yml new file mode 100644 index 000000000..6d752a802 --- /dev/null +++ b/.github/workflows/job.tests.yml @@ -0,0 +1,146 @@ +name: "Tests" + +"on": + workflow_dispatch: {} + workflow_call: + inputs: + native: + description: "Native Tests" + default: false + type: boolean + runner: + description: "Runner" + default: "ubuntu-latest" + type: string + + secrets: + GRADLE_CONFIGURATION_KEY: + description: "Gradle cache key" + required: false + CODECOV_TOKEN: + description: "Codecov token" + required: false + BUILDLESS_APIKEY: + description: "Buildless key" + required: false + +permissions: + contents: read + +jobs: + ## + ## Job: Testsuite + ## + gradle: + name: "Testsuite" + runs-on: ${{ inputs.runner || 'ubuntu-latest' }} + + defaults: + run: + shell: bash + + outputs: + hashes: ${{ steps.hash.outputs.hashes }} + + steps: + - name: "Setup: Harden Runner" + uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0 + with: + egress-policy: audit + - name: "Setup: Checkout" + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + submodules: true + persist-credentials: false + - name: "Setup: Cache Restore (Build)" + id: cache-restore-build + uses: actions/cache/restore@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0 + with: + key: pkl-v1-build-${{ hashFiles('gradle/libs.versions.toml') }} + restore-keys: | + pkl-v1-build-${{ hashFiles('gradle/libs.versions.toml') }} + pkl-v1-build- + pkl-v1- + pkl- + path: | + .gradle/ + build/ + .codebase/ + .kotlin/ + ./*/build/bin + ./*/build/classes + ./*/build/kotlin + ./*/build/klib + ./*/build/generated + ./*/build/generated-sources + - name: "Setup: Java 21" + uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 # v4.0.0 + with: + distribution: 'adopt' + java-version: '21' + - name: "Setup: GraalVM (Java 21)" + uses: graalvm/setup-graalvm@d72e3dbf5f44eb0b78c4f8ec61a262d8bf9b94af # v1.1.7 + with: + distribution: "graalvm" + java-version: 21 + check-for-updates: false + github-token: ${{ secrets.GITHUB_TOKEN }} + set-java-home: 'false' + - name: "🛠️ JVM Testsuite" + uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0 + id: gradlebuild + env: + CI: true + with: + cache-read-only: true + cache-encryption-key: ${{ secrets.GRADLE_CONFIGURATION_KEY }} + gradle-home-cache-cleanup: true + build-scan-publish: true + build-scan-terms-of-service-url: "https://gradle.com/terms-of-service" + build-scan-terms-of-service-agree: "yes" + arguments: | + test + koverVerify + koverXmlReport + koverHtmlReport + koverBinaryReport + reports + -x check + --continue + --scan + - name: "Artifact: Test Reports" + uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 + if: success() || failure() + with: + name: "pkl-test-reports-${{ github.sha }}" + if-no-files-found: warn + retention-days: 7 + compression-level: 4 + overwrite: true + path: | + ./build/reports + ./pkl-*/build/reports + ./build/reports/* + ./pkl-*/build/reports/* + - name: "Reporting: Coverage" + uses: codecov/codecov-action@e0b68c6749509c5f83f984dd99a76a1c1a231044 # v4.0.1 + continue-on-error: true + if: success() + with: + token: ${{ secrets.CODECOV_TOKEN }} + slug: elide-dev/pkl + - name: "Artifact: Caches" + uses: actions/cache/save@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0 + with: + key: ${{ steps.cache-restore.outputs.cache-primary-key }} + path: | + .gradle/ + build/ + .codebase/ + .kotlin/ + ./*/build/bin + ./*/build/classes + ./*/build/kotlin + ./*/build/klib + ./*/build/generated + ./*/build/generated-sources diff --git a/.github/workflows/on.pr.yml b/.github/workflows/on.pr.yml new file mode 100644 index 000000000..a9550b54b --- /dev/null +++ b/.github/workflows/on.pr.yml @@ -0,0 +1,195 @@ +name: "PR" + +# Labels to control this PR flow: +# +# - ci:api-check-bypass - Bypass API check failures. +# - ci:fmt-ignore - Ignore formatting failures. + +"on": + pull_request: + types: [opened, reopened, synchronize] + +permissions: + contents: read + +concurrency: + group: "pr-${{ github.event.pull_request.number }}" + cancel-in-progress: true + +jobs: + ## + ## Job: Pre-flight Checks + ## + preflight-checks: + name: "Pre-flight Checks" + runs-on: ${{ vars.RUNNER_DEFAULT || 'ubuntu-latest' }} + permissions: + contents: "read" + checks: "read" + packages: "read" + steps: + - name: "Setup: Harden Runner" + uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0 + with: + egress-policy: audit + - name: "Setup: Checkout" + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + submodules: true + persist-credentials: false + - name: "Setup: Java 21" + uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 # v4.0.0 + with: + distribution: 'adopt' + java-version: '21' + - name: "Setup: GraalVM (Java 21)" + uses: graalvm/setup-graalvm@d72e3dbf5f44eb0b78c4f8ec61a262d8bf9b94af # v1.1.7 + with: + distribution: "graalvm" + java-version: "21" + github-token: ${{ secrets.GITHUB_TOKEN }} + set-java-home: 'false' + - name: "Check: Build Compile" + uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0 + continue-on-error: ${{ contains(github.event.pull_request.labels.*.name, 'ci:api-check-bypass') }} + env: + CI: true + GITHUB_ACTOR: ${{ env.GITHUB_ACTOR }} + BUILDLESS_APIKEY: ${{ secrets.BUILDLESS_APIKEY }} + with: + cache-read-only: false + build-scan-publish: true + build-scan-terms-of-service-url: "https://gradle.com/terms-of-service" + build-scan-terms-of-service-agree: "yes" + cache-encryption-key: ${{ secrets.GRADLE_CONFIGURATION_KEY }} + arguments: | + projects + tasks + --scan + + ## + ## Job: Build + ## + build: + name: "Build" + uses: ./.github/workflows/job.build.yml + needs: [preflight-checks] + secrets: + GRADLE_CONFIGURATION_KEY: ${{ secrets.GRADLE_CONFIGURATION_KEY }} + BUILDLESS_APIKEY: ${{ secrets.BUILDLESS_APIKEY }} + + ## + ## Job: Native Build + ## + native-build: + name: "Build" + uses: ./.github/workflows/job.native-build.yml + needs: [preflight-checks, build] + secrets: + GRADLE_CONFIGURATION_KEY: ${{ secrets.GRADLE_CONFIGURATION_KEY }} + BUILDLESS_APIKEY: ${{ secrets.BUILDLESS_APIKEY }} + permissions: + contents: "read" + + ## + ## Job: Tests + ## + pr-tests: + name: "Tests" + uses: ./.github/workflows/job.tests.yml + needs: [preflight-checks, build] + secrets: + GRADLE_CONFIGURATION_KEY: ${{ secrets.GRADLE_CONFIGURATION_KEY }} + BUILDLESS_APIKEY: ${{ secrets.BUILDLESS_APIKEY }} + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + + ## + ## Job: Submit Dependency Graph + ## + dependency-graph: + name: "Checks" + uses: ./.github/workflows/job.dependency-graph.yml + needs: [preflight-checks] + secrets: + GRADLE_CONFIGURATION_KEY: ${{ secrets.GRADLE_CONFIGURATION_KEY }} + BUILDLESS_APIKEY: ${{ secrets.BUILDLESS_APIKEY }} + permissions: + ## Needed for build graph publishing + contents: "write" + + ## + ## Job: API Check + ## + check-api: + name: "Checks" + uses: ./.github/workflows/checks.apicheck.yml + needs: [preflight-checks] + secrets: + GRADLE_CONFIGURATION_KEY: ${{ secrets.GRADLE_CONFIGURATION_KEY }} + BUILDLESS_APIKEY: ${{ secrets.BUILDLESS_APIKEY }} + permissions: + contents: "read" + + ## + ## Job: Checks for Formatting/Style + ## + check-format: + name: "Checks" + uses: ./.github/workflows/checks.formatting.yml + needs: [preflight-checks] + permissions: + contents: "read" + secrets: + GRADLE_CONFIGURATION_KEY: ${{ secrets.GRADLE_CONFIGURATION_KEY }} + BUILDLESS_APIKEY: ${{ secrets.BUILDLESS_APIKEY }} + with: + ignore_failures: ${{ contains(github.event.pull_request.labels.*.name, 'ci:fmt-ignore') }} + + ## + ## Job: Check for Wrapper + ## + check-wrapper: + name: "Checks" + uses: ./.github/workflows/checks.gradle-wrapper.yml + needs: [preflight-checks] + permissions: + contents: "read" + + ## + ## Job: Checks for Vulnerabilities/Licensing + ## + check-dependencies: + name: "Checks" + uses: ./.github/workflows/checks.dependency-review.yml + needs: [preflight-checks, dependency-graph] + permissions: + contents: "read" + + ## + ## Job: Checks with CodeQL + ## + check-codeql: + name: "Checks" + uses: ./.github/workflows/checks.codeql.yml + needs: [preflight-checks, dependency-graph] + secrets: + GRADLE_CONFIGURATION_KEY: ${{ secrets.GRADLE_CONFIGURATION_KEY }} + BUILDLESS_APIKEY: ${{ secrets.BUILDLESS_APIKEY }} + permissions: + actions: "read" + contents: "read" + security-events: "write" + + ## + ## Job: Checks with Detekt + ## + check-detekt: + name: "Checks" + uses: ./.github/workflows/checks.detekt.yml + needs: [preflight-checks] + secrets: + GRADLE_CONFIGURATION_KEY: ${{ secrets.GRADLE_CONFIGURATION_KEY }} + BUILDLESS_APIKEY: ${{ secrets.BUILDLESS_APIKEY }} + permissions: + contents: "read" + security-events: "write" diff --git a/.github/workflows/on.push.yml b/.github/workflows/on.push.yml new file mode 100644 index 000000000..4689e0622 --- /dev/null +++ b/.github/workflows/on.push.yml @@ -0,0 +1,80 @@ +name: "CI" + +"on": + merge_group: {} + push: + branches: + - main + +permissions: + contents: read + +concurrency: + group: "push-${{ github.sha }}" + +jobs: + ## + ## Job: Build Dependency Graph + ## + build-graph: + name: "Checks" + uses: ./.github/workflows/job.dependency-graph.yml + permissions: + ## Needed for submission of dependency graphs + contents: "write" + + ## + ## Job: Build + ## + build: + name: "Build" + uses: ./.github/workflows/job.build.yml + needs: [preflight-checks] + secrets: + GRADLE_CONFIGURATION_KEY: ${{ secrets.GRADLE_CONFIGURATION_KEY }} + BUILDLESS_APIKEY: ${{ secrets.BUILDLESS_APIKEY }} + + ## + ## Job: Tests + ## + tests: + name: "Tests" + uses: ./.github/workflows/job.tests.yml + needs: [build] + secrets: + GRADLE_CONFIGURATION_KEY: ${{ secrets.GRADLE_CONFIGURATION_KEY }} + BUILDLESS_APIKEY: ${{ secrets.BUILDLESS_APIKEY }} + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + + ## + ## Job: Checks with Detekt + ## + check-detekt: + name: "Checks" + uses: ./.github/workflows/checks.detekt.yml + needs: [preflight-checks] + permissions: + contents: "read" + security-events: "write" + + ## + ## Job: Checks with Scorecard + ## + check-scorecard: + name: "Checks" + uses: ./.github/workflows/checks.scorecards.yml + needs: [build-graph] + permissions: + actions: "read" + contents: "read" + checks: "read" + deployments: "read" + discussions: "read" + id-token: "write" + issues: "read" + packages: "read" + pages: "read" + pull-requests: "read" + repository-projects: "read" + security-events: "write" + statuses: "read" diff --git a/.gitignore b/.gitignore index 4c1ed3a12..82fa57f8e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ # macOS .DS_STORE +.codebase/ # Gradle .gradle/ @@ -18,3 +19,6 @@ generated/ # :pkl-core:makeIntelliJAntlrPluginHappy gen/ PklLexer.tokens + +gradle-user-home +profile-out diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml index afb7ce46c..1fa98d1f5 100644 --- a/.idea/codeStyles/Project.xml +++ b/.idea/codeStyles/Project.xml @@ -239,10 +239,8 @@ -