diff --git a/.github/workflows/ci-failure-slack.yml b/.github/workflows/ci-failure-slack.yml new file mode 100644 index 0000000..9b33d4a --- /dev/null +++ b/.github/workflows/ci-failure-slack.yml @@ -0,0 +1,59 @@ +# Generated by sbt-lucuma's lucumaSlackNotifyGenerate. Do not edit by hand; change the +# `lucumaSlackNotify*` settings in build.sbt and regenerate. +# +# GitHub only notifies the actor who triggered a run, and merges are pushed by a bot, so a +# red `main` would otherwise reach nobody. Watching whole workflows means jobs added +# later are covered without touching this file. +name: CI Failure Notification + +on: + workflow_run: + workflows: [Continuous Integration] + types: [completed] + branches: [main] + +permissions: + actions: read + contents: read + +jobs: + notify: + name: Notify Slack + if: ${{ github.event.workflow_run.conclusion == 'failure' || github.event.workflow_run.conclusion == 'timed_out' }} + runs-on: ubuntu-22.04 + steps: + # Best effort, and deliberately tolerant: a transient API failure here must not cost + # us the notification, which is the whole point of this workflow. + - name: Collect failed jobs + id: failed + continue-on-error: true + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + set -uo pipefail + jobs=$(gh api --paginate \ + "repos/${{ github.repository }}/actions/runs/${{ github.event.workflow_run.id }}/jobs" \ + -q '.jobs[] | select(.conclusion == "failure" or .conclusion == "timed_out") | .name' \ + | paste -sd ', ' - || true) + echo "jobs=${jobs:-unknown}" >> "$GITHUB_OUTPUT" + + - name: Post to Slack + env: + GPP_SLACK_WEBHOOK_URL: ${{ secrets.GPP_SLACK_WEBHOOK_URL }} + FAILED_JOBS: ${{ steps.failed.outputs.jobs }} + RUN_URL: ${{ github.event.workflow_run.html_url }} + HEAD_SHA: ${{ github.event.workflow_run.head_sha }} + ACTOR: ${{ github.event.workflow_run.actor.login }} + WORKFLOW: ${{ github.event.workflow_run.name }} + CONCLUSION: ${{ github.event.workflow_run.conclusion }} + run: | + set -euo pipefail + if [ -z "${GPP_SLACK_WEBHOOK_URL:-}" ]; then + echo "::warning::GPP_SLACK_WEBHOOK_URL is not set; skipping the Slack notification" + exit 0 + fi + text=$(printf ':x: *%s* %s %s on `%s`\n*Failed:* %s\n*Commit:* `%s` (%s)\n%s' \ + "${{ github.repository }}" "$WORKFLOW" "$CONCLUSION" "main" \ + "${FAILED_JOBS:-unknown}" "${HEAD_SHA:0:8}" "$ACTOR" "$RUN_URL") + jq -n --arg text "$text" '{text: $text}' \ + | curl -sS --fail-with-body -X POST -H 'Content-type: application/json' --data @- "$GPP_SLACK_WEBHOOK_URL" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e3e7828..6136c3f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -59,14 +59,14 @@ jobs: - name: Check headers and formatting if: matrix.java == 'temurin@25' && matrix.os == 'ubuntu-22.04' - run: sbt '++ ${{ matrix.scala }}' headerCheckAll scalafmtCheckAll 'project /' scalafmtSbtCheck lucumaScalafmtCheck lucumaScalafixCheck + run: sbt '++ ${{ matrix.scala }}' headerCheckAll scalafmtCheckAll 'project /' scalafmtSbtCheck lucumaScalafmtCheck lucumaScalafixCheck lucumaSlackNotifyCheck - name: Check scalafix lints if: matrix.java == 'temurin@25' && matrix.os == 'ubuntu-22.04' run: sbt '++ ${{ matrix.scala }}' 'scalafixAll --check' - - name: Test - run: sbt '++ ${{ matrix.scala }}' test + - name: Test affected projects + run: sbt '++ ${{ matrix.scala }}' lucumaTestAffected - name: Check binary compatibility if: matrix.java == 'temurin@25' && matrix.os == 'ubuntu-22.04' @@ -76,11 +76,20 @@ jobs: if: matrix.java == 'temurin@25' && matrix.os == 'ubuntu-22.04' run: sbt '++ ${{ matrix.scala }}' doc - - name: Aggregate coverage reports - run: sbt '++ ${{ matrix.scala }}' coverageReport coverageAggregate + - name: Make target directories + if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/master') + run: mkdir -p target project/target - - name: Upload code coverage data - uses: codecov/codecov-action@v6 + - name: Compress target directories + if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/master') + run: tar cf targets.tar target project/target + + - name: Upload target directories + if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/master') + uses: actions/upload-artifact@v5 + with: + name: target-${{ matrix.os }}-${{ matrix.java }}-${{ matrix.scala }} + path: targets.tar publish: name: Publish Artifacts @@ -113,6 +122,16 @@ jobs: if: matrix.java == 'temurin@25' && steps.setup-java-temurin-25.outputs.cache-hit == 'false' run: sbt +update + - name: Download target directories (3) + uses: actions/download-artifact@v6 + with: + name: target-${{ matrix.os }}-${{ matrix.java }}-3 + + - name: Inflate target directories (3) + run: | + tar xf targets.tar + rm targets.tar + - name: Import signing key if: env.PGP_SECRET != '' && env.PGP_PASSPHRASE == '' env: @@ -136,3 +155,21 @@ jobs: SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} SONATYPE_CREDENTIAL_HOST: ${{ secrets.SONATYPE_CREDENTIAL_HOST }} run: sbt tlCiRelease + + required-checks: + name: REQUIRED CHECKS FOR BRANCH PROTECTION - AGGREGATED + needs: [build] + if: always() + strategy: + matrix: + os: [ubuntu-latest] + runs-on: ${{ matrix.os }} + steps: + - name: Fail if a required job did not pass + if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') + run: | + echo "::error::a required job did not pass" + exit 1 + + - name: Report success + run: echo "all of build passed or were skipped" diff --git a/project/plugins.sbt b/project/plugins.sbt index bdb8fce..7413748 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -2,6 +2,6 @@ addSbtPlugin("io.github.cquiroz" % "sbt-tzdb" % "5.0.0") addSbtPlugin("io.github.cquiroz" % "sbt-locales" % "4.5.0") -addSbtPlugin("edu.gemini" % "sbt-lucuma-lib" % "0.14.20") +addSbtPlugin("edu.gemini" % "sbt-lucuma-lib" % "0.16.2") evictionErrorLevel := Level.Info