From b86ea337d1d24e0fe258780fcb9b70828b7c6ede Mon Sep 17 00:00:00 2001 From: Lucas Schwiderski Date: Thu, 23 Nov 2023 15:23:02 +0100 Subject: [PATCH 1/2] Fix build script --- .ci/image/Dockerfile.linux | 1 + .ci/tasks/build.sh | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.ci/image/Dockerfile.linux b/.ci/image/Dockerfile.linux index 4927810..df10059 100644 --- a/.ci/image/Dockerfile.linux +++ b/.ci/image/Dockerfile.linux @@ -5,6 +5,7 @@ RUN set -eux; \ apt-get install --no-install-recommends -y \ build-essential \ curl \ + git \ gpg \ jq \ libatk1.0-dev \ diff --git a/.ci/tasks/build.sh b/.ci/tasks/build.sh index 4c70a10..9d294b8 100755 --- a/.ci/tasks/build.sh +++ b/.ci/tasks/build.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash set -eu @@ -16,7 +16,7 @@ cd "repo" if [ -n "${PR:-}" ]; then title "PR: $(echo "$PR" | jq '.number') - $(echo "$PR" | jq '.title')" - ref="pr-$(echo "$PR" | jq '.number')-$(git rev-parse --short $(cat .git/ref || echo "HEAD")) 2>/dev/null || echo 'manual')" + ref="pr-$(echo "$PR" | jq '.number')-$(git rev-parse --short "$(cat .git/ref || echo "HEAD")" 2>/dev/null || echo 'manual')" else ref=$(git describe --tags) fi From 92546f6f5edddc5909d8ad938278aab905f41350 Mon Sep 17 00:00:00 2001 From: Lucas Schwiderski Date: Thu, 23 Nov 2023 15:23:40 +0100 Subject: [PATCH 2/2] Fix pipeline status Since the PR pipeline is not re-applied on new commits, the `pr.head.ref` variable doesn't get updated, and isn't suitable for the status reporting. --- .ci/pipelines/base-pipeline.yml | 2 +- .ci/pipelines/pr.yml | 39 +++++++++++++++++++++++---------- Justfile | 4 ++-- 3 files changed, 30 insertions(+), 15 deletions(-) diff --git a/.ci/pipelines/base-pipeline.yml b/.ci/pipelines/base-pipeline.yml index ae9e323..f231fb7 100644 --- a/.ci/pipelines/base-pipeline.yml +++ b/.ci/pipelines/base-pipeline.yml @@ -40,4 +40,4 @@ jobs: pr: ((.:pr)) gitea_api_key: ((gitea_api_key)) instance_vars: - n: ((.:pr.number)) + number: ((.:pr.number)) diff --git a/.ci/pipelines/pr.yml b/.ci/pipelines/pr.yml index 146f987..a9060f9 100644 --- a/.ci/pipelines/pr.yml +++ b/.ci/pipelines/pr.yml @@ -37,7 +37,6 @@ resources: url: http://forgejo:3000 owner: bitsquid_dt repo: dtmt - sha: ((pr.head.sha)) context: lint/clippy description: Checking for common mistakes and opportunities for code improvement @@ -48,7 +47,6 @@ resources: url: http://forgejo:3000 owner: bitsquid_dt repo: dtmt - sha: ((pr.head.sha)) context: build/msvc description: "Build for the target platform: msvc" @@ -59,7 +57,6 @@ resources: url: http://forgejo:3000 owner: bitsquid_dt repo: dtmt - sha: ((pr.head.sha)) context: build/linux description: "Build for the target platform: linux" @@ -72,6 +69,7 @@ jobs: no_get: true params: state: success + sha: ((.:git_sha)) on_failure: put: state-failure @@ -79,16 +77,21 @@ jobs: no_get: true params: state: failure + sha: ((.:git_sha)) plan: + - get: repo + trigger: true + + - load_var: git_sha + file: repo/.git/ref + - put: state-pending resource: pr-status-lint-clippy no_get: true params: state: pending - - - get: repo - trigger: true + sha: ((.:git_sha)) - task: check file: repo/.ci/tasks/clippy.yml @@ -103,6 +106,7 @@ jobs: no_get: true params: state: success + sha: ((.:git_sha)) on_failure: put: state-failure @@ -110,16 +114,21 @@ jobs: no_get: true params: state: failure + sha: ((.:git_sha)) plan: + - get: repo + trigger: true + + - load_var: git_sha + file: repo/.git/ref + - put: state-pending resource: pr-status-build-msvc no_get: true params: state: pending - - - get: repo - trigger: true + sha: ((.:git_sha)) - task: build file: repo/.ci/tasks/build.yml @@ -154,6 +163,7 @@ jobs: no_get: true params: state: success + sha: ((.:git_sha)) on_failure: put: state-failure @@ -161,16 +171,21 @@ jobs: no_get: true params: state: failure + sha: ((.:git_sha)) plan: + - get: repo + trigger: true + + - load_var: git_sha + file: repo/.git/ref + - put: state-pending resource: pr-status-build-linux no_get: true params: state: pending - - - get: repo - trigger: true + sha: ((.:git_sha)) - task: build file: repo/.ci/tasks/build.yml diff --git a/Justfile b/Justfile index 964dc1f..70af61a 100644 --- a/Justfile +++ b/Justfile @@ -29,7 +29,7 @@ ci-image-linux: docker push registry.sclu1034.dev/dtmt-ci-base-linux set-base-pipeline: - fly -t ((fly_target)) set-pipeline \ + fly -t {{fly_target}} set-pipeline \ --pipeline dtmt-prs \ --config .ci/pipelines/base-pipeline.yml \ -v gitea_api_key=${GITEA_API_KEY} \ @@ -46,7 +46,7 @@ set-pr-pipeline pr: --pipeline dtmt-pr \ --config .ci/pipelines/pr.yml \ -v gitea_api_key=${GITEA_API_KEY} \ - -i n={{pr}} \ + -i number={{pr}} \ -y branch="$(yq -y '.head.ref' 'pr-{{pr}}.yaml')" \ -y pr="$(cat 'pr-{{pr}}.yaml')"