From db6a117f732721335f4981c399abc5302c9f8deb Mon Sep 17 00:00:00 2001 From: Paul Brauner Date: Tue, 24 Sep 2024 09:47:57 +0200 Subject: [PATCH] try out checkboxes --- ci/bash-lib.yml | 7 +++ ci/prs.yml | 147 +++++------------------------------------------- 2 files changed, 21 insertions(+), 133 deletions(-) diff --git a/ci/bash-lib.yml b/ci/bash-lib.yml index de971aac4ca4..4cd5ceae212c 100644 --- a/ci/bash-lib.yml +++ b/ci/bash-lib.yml @@ -100,6 +100,13 @@ steps: jq -n --arg message "$message" '{"text": $message}' \ | curl -XPOST -i -H 'Content-Type: application/json' -d @- $channel } + tell_slack_blocks() { + local message channel + message="$1" + channel=${2:-$(Slack.team-daml)} + jq -n "{\"blocks\": $message}" \ + | curl -XPOST -i -H 'Content-Type: application/json' -d @- $channel + } wrap_gcloud() ( cred="$1" cmd="$2" diff --git a/ci/prs.yml b/ci/prs.yml index 0b7b3578681e..a4c7e0420a5b 100644 --- a/ci/prs.yml +++ b/ci/prs.yml @@ -12,143 +12,24 @@ pr: - release/* jobs: -- template: build.yml - parameters: - test_mode: pr -- template: check-for-release-job.yml - - -- job: check_standard_change_label - dependsOn: - - check_for_release - condition: and(eq(variables['Build.Reason'], 'PullRequest'), - eq(dependencies.check_for_release.outputs['out.is_release'], 'true')) - pool: - name: 'ubuntu_20_04' - demands: assignment -equals default - steps: - - checkout: self - - bash: | - set -euo pipefail - - curl https://api.github.com/repos/digital-asset/daml/pulls/$PR -s | jq -r '.labels[].name' | grep -q '^Standard-Change$' - env: - PR: $(System.PullRequest.PullRequestNumber) - -# required for collect_build_data -- job: release - condition: false - -- job: notify_release_pr - condition: and(not(canceled()), - or(startsWith(variables['Build.SourceBranchName'], 'auto-release-pr-'), - startsWith(variables['System.PullRequest.SourceBranch'], 'auto-release-pr-')), - eq(dependencies.check_for_release.outputs['out.is_release'], 'true')) - dependsOn: - - git_sha - - collect_build_data - - check_for_release - - platform_independence_test - pool: - name: 'ubuntu_20_04' - demands: assignment -equals default - variables: - branch_sha: $[ dependencies.git_sha.outputs['out.branch'] ] - status: $[ dependencies.collect_build_data.result ] - is_release: $[ dependencies.check_for_release.outputs['out.is_release'] ] - steps: - - checkout: self - persistCredentials: true + - job: report + pool: + name: ubuntu_20_04 + demands: assignment -equals default + steps: - template: bash-lib.yml parameters: - var_name: bash-lib + var_name: bash_lib - bash: | set -euo pipefail - source $(bash-lib) + cd sdk + eval "$(./dev-env/bin/dade-assist)" + source $(bash_lib) - AUTH="$(get_gh_auth_header)" - PR=$(curl -H "$AUTH" \ - -H "Accept: application/vnd.github.groot-preview+json" \ - -s -f \ - "https://api.github.com/repos/digital-asset/daml/commits/$(git rev-parse HEAD)/pulls" \ - | jq '.[0].number' \ - || echo "") - # Note: if we somehow fail to resolve the PR number from the GitHub - # API, there is still value in getting the notification on Slack, as - # we do have the build number and from there we can click through to - # the PR. Hence the `|| echo ""`. - PR_HANDLER=$(next_in_rotation_slack) - case "$(status)" in - Succeeded*) - msg="has succeeded! Next step is to approve & merge. This is probably a good time to start your Windows testing machine." - ;; - Failed*) - msg="has failed. Please investigate." - ;; - *) - # Should not be reached, but who knows? - msg="has completed with status $(status). See for what to do next." - ;; - esac - tell_slack "<@${PR_HANDLER}> for release PR $msg" - -- job: notify_user - # No Slack tokens on forks - condition: and(not(canceled()), - eq(variables['System.PullRequest.IsFork'], 'False')) - dependsOn: - - git_sha - - collect_build_data - - check_for_release - pool: - name: 'ubuntu_20_04' - demands: assignment -equals default - variables: - pr.num: $[ variables['System.PullRequest.PullRequestNumber'] ] - branch_sha: $[ dependencies.git_sha.outputs['out.branch'] ] - build_status: $[ dependencies.collect_build_data.result ] - steps: - - template: bash-lib.yml - parameters: - var_name: bash-lib - - bash: | - set -euo pipefail - source $(bash-lib) - - user=$(user_slack_handle $(branch_sha)) - if [ "$user" != "" ]; then - tell_slack "<@${user}> for has completed with status $(build_status)." \ - "$(Slack.team-daml-ci)" - fi - if [ "$(git log -n1 --format="%(trailers:key=tell-slack,valueonly)" HEAD)" = "canton" ]; then - if [ "$(build_status)" = "Failed" ]; then - tell_slack " for has completed with status $(build_status)." \ - "$(Slack.team-canton-notifications)" - fi - fi - -- job: self_service_compat_test - pool: - name: 'ubuntu_20_04' - demands: assignment -equals default - condition: eq(variables['Build.Reason'], 'PullRequest') - steps: - - checkout: self - - template: bash-lib.yml - parameters: - var_name: bash-lib - - bash: | - set -euo pipefail - cd sdk - eval "$(./dev-env/bin/dade-assist)" - source $(bash-lib) - COMMIT=$(git rev-parse HEAD^2) - REQUEST=$(git log -n1 --format="%(trailers:key=run-full-compat,valueonly)" $COMMIT) - if [ $REQUEST == true ]; then - # Unfortunately recovering the actual branch name is tricky - trigger_azure $AZURE_TOKEN digital-asset.daml-daily-compat --commit-id $COMMIT --branch not-main - fi - env: - AZURE_TOKEN: $(System.AccessToken) + export GH_REPO=digital-asset/daml + message='[ { "type": "section", "text": { "type": "mrkdwn", "text": "*THIS IS A TEST PLEASE IGNORE*\n\nOpen daml repo PRs to address:" }, "accessory": { "type": "checkboxes", "options": [ { "text": { "type": "mrkdwn", "text": "2024-24-09" }, "description": { "type": "mrkdwn", "text": "" } }, { "text": { "type": "mrkdwn", "text": "2024-24-08" }, "description": { "type": "mrkdwn", "text": "" } } ] } } ]' + tell_slack_blocks "$message" "$(Slack.team-sdk-updates)" + env: + GITHUB_TOKEN: $(CANTON_READONLY_TOKEN)