From 4ec831579bf2fe6bab2cb3b7d4ff9f15bb0c24b3 Mon Sep 17 00:00:00 2001 From: Julio Guerra Date: Thu, 4 Apr 2024 14:59:38 +0200 Subject: [PATCH 1/8] ci: composite re2 action --- .github/actions/pr-metadata/action.yml | 21 +++++++++++++++++++ .github/actions/pr-metadata/re.go | 29 ++++++++++++++++++++++++++ .github/workflows/system-tests.yml | 10 +++++---- 3 files changed, 56 insertions(+), 4 deletions(-) create mode 100644 .github/actions/pr-metadata/action.yml create mode 100644 .github/actions/pr-metadata/re.go diff --git a/.github/actions/pr-metadata/action.yml b/.github/actions/pr-metadata/action.yml new file mode 100644 index 0000000000..834dfcf79f --- /dev/null +++ b/.github/actions/pr-metadata/action.yml @@ -0,0 +1,21 @@ +name: 'Pull Request Metadata' +description: 'Read JSON metadata from Pull Request descriptions' +inputs: + text: + description: 'Text to parse for metadata' + required: true +outputs: + metadata: + description: "JSON metadata from the input text" + value: ${{ fromJSON(steps.random.outputs.metadata) }} +runs: + using: "composite" + steps: + - uses: actions/setup-go@v5 + with: + cache: false + + - name: Parse Text Metadata + id: parse + shell: bash + run: echo "metadata=$(go run .github/actions/pr-metadata/re.go "${{ inputs.text }}") >> $GITHUB_OUTPUT diff --git a/.github/actions/pr-metadata/re.go b/.github/actions/pr-metadata/re.go new file mode 100644 index 0000000000..7727aa8223 --- /dev/null +++ b/.github/actions/pr-metadata/re.go @@ -0,0 +1,29 @@ +// Unless explicitly stated otherwise all files in this repository are licensed +// under the Apache License Version 2.0. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2016-present Datadog, Inc. + +package main + +import ( + "fmt" + "log" + "os" + "regexp" +) + +func main() { + if len(os.Args) < 2 { + log.Fatalf("Usage: %s \"\"", os.Args[0]) + return + } + + re := regexp.MustCompile(``) + text := os.Args[1] + matches := re.FindStringSubmatch(text) + if len(matches) <= 1 { + return + } + + fmt.Println(matches[1]) +} diff --git a/.github/workflows/system-tests.yml b/.github/workflows/system-tests.yml index a5163c6115..9145b6b3e9 100644 --- a/.github/workflows/system-tests.yml +++ b/.github/workflows/system-tests.yml @@ -30,9 +30,7 @@ on: jobs: system-tests: if: github.event_name != 'pull_request' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == 'DataDog/dd-trace-go') - # Note: Not using large runners because the jobs spawned by this pipeline - # don't seem to get a noticable speedup from using larger runners. - runs-on: ubuntu-latest + runs-on: ubuntu-latest-16-cores strategy: matrix: weblog-variant: @@ -125,8 +123,12 @@ jobs: - name: Build agent run: ./build.sh -i agent + - uses: ./.github/actions/pr-metadata + with: + text: ${{ github.event.pull_request.description }} + - name: Run - run: env ${{ matrix.env }} ./run.sh ${{ matrix.scenario }} + run: exit 1; env ${{ matrix.env }} ./run.sh ${{ matrix.scenario }} - name: Compress artifact if: ${{ always() }} From 8da8d41535f3597bcb93bbfdadc194fb5f76c3d5 Mon Sep 17 00:00:00 2001 From: Julio Guerra Date: Thu, 4 Apr 2024 15:07:14 +0200 Subject: [PATCH 2/8] ci: composite action --- .github/workflows/system-tests.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/system-tests.yml b/.github/workflows/system-tests.yml index 9145b6b3e9..ddedb5402b 100644 --- a/.github/workflows/system-tests.yml +++ b/.github/workflows/system-tests.yml @@ -114,6 +114,10 @@ jobs: ref: ${{ inputs.branch_ref || github.ref }} path: 'binaries/dd-trace-go' + - uses: binaries/dd-trace-go/.github/actions/pr-metadata + with: + text: ${{ github.event.pull_request.description }} + - name: Build weblog run: ./build.sh -i weblog @@ -123,10 +127,6 @@ jobs: - name: Build agent run: ./build.sh -i agent - - uses: ./.github/actions/pr-metadata - with: - text: ${{ github.event.pull_request.description }} - - name: Run run: exit 1; env ${{ matrix.env }} ./run.sh ${{ matrix.scenario }} From 51512c208e93160bd8d58720b2fa77a2258d9f97 Mon Sep 17 00:00:00 2001 From: Julio Guerra Date: Thu, 4 Apr 2024 15:08:34 +0200 Subject: [PATCH 3/8] ci: composite action --- .github/workflows/system-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/system-tests.yml b/.github/workflows/system-tests.yml index ddedb5402b..0cb27280f6 100644 --- a/.github/workflows/system-tests.yml +++ b/.github/workflows/system-tests.yml @@ -114,7 +114,7 @@ jobs: ref: ${{ inputs.branch_ref || github.ref }} path: 'binaries/dd-trace-go' - - uses: binaries/dd-trace-go/.github/actions/pr-metadata + - uses: ./binaries/dd-trace-go/.github/actions/pr-metadata with: text: ${{ github.event.pull_request.description }} From 7198f09b3680b943eef78c2062ced0e023e1307d Mon Sep 17 00:00:00 2001 From: Julio Guerra Date: Thu, 4 Apr 2024 15:26:46 +0200 Subject: [PATCH 4/8] ci: composite action --- .github/actions/pr-metadata/action.yml | 2 +- .github/workflows/system-tests.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/actions/pr-metadata/action.yml b/.github/actions/pr-metadata/action.yml index 834dfcf79f..3fc6ad2a4e 100644 --- a/.github/actions/pr-metadata/action.yml +++ b/.github/actions/pr-metadata/action.yml @@ -7,7 +7,7 @@ inputs: outputs: metadata: description: "JSON metadata from the input text" - value: ${{ fromJSON(steps.random.outputs.metadata) }} + value: ${{ fromJSON(steps.parse.outputs.metadata) }} runs: using: "composite" steps: diff --git a/.github/workflows/system-tests.yml b/.github/workflows/system-tests.yml index 0cb27280f6..f225c7c9f3 100644 --- a/.github/workflows/system-tests.yml +++ b/.github/workflows/system-tests.yml @@ -116,7 +116,7 @@ jobs: - uses: ./binaries/dd-trace-go/.github/actions/pr-metadata with: - text: ${{ github.event.pull_request.description }} + text: ${{ github.event.pull_request.body }} - name: Build weblog run: ./build.sh -i weblog From 7b05b43a03176d348a4328f6d7fec04845480893 Mon Sep 17 00:00:00 2001 From: Julio Guerra Date: Thu, 4 Apr 2024 15:29:39 +0200 Subject: [PATCH 5/8] ci: composite action --- .github/actions/pr-metadata/action.yml | 2 +- .github/workflows/system-tests.yml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/actions/pr-metadata/action.yml b/.github/actions/pr-metadata/action.yml index 3fc6ad2a4e..de121952a3 100644 --- a/.github/actions/pr-metadata/action.yml +++ b/.github/actions/pr-metadata/action.yml @@ -18,4 +18,4 @@ runs: - name: Parse Text Metadata id: parse shell: bash - run: echo "metadata=$(go run .github/actions/pr-metadata/re.go "${{ inputs.text }}") >> $GITHUB_OUTPUT + run: echo "metadata=$(go run .github/actions/pr-metadata/re.go \"${{ inputs.text }}\") >> $GITHUB_OUTPUT diff --git a/.github/workflows/system-tests.yml b/.github/workflows/system-tests.yml index f225c7c9f3..433138ab13 100644 --- a/.github/workflows/system-tests.yml +++ b/.github/workflows/system-tests.yml @@ -114,6 +114,7 @@ jobs: ref: ${{ inputs.branch_ref || github.ref }} path: 'binaries/dd-trace-go' + - run: echo ${{ toJSON(github.event) }} - uses: ./binaries/dd-trace-go/.github/actions/pr-metadata with: text: ${{ github.event.pull_request.body }} From 765e3637b4c5432d354c695b0d9d642904b56034 Mon Sep 17 00:00:00 2001 From: Julio Guerra Date: Thu, 4 Apr 2024 16:46:19 +0200 Subject: [PATCH 6/8] ci: composite action --- .github/actions/pr-metadata/action.yml | 6 +++++- .github/workflows/system-tests.yml | 2 -- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/actions/pr-metadata/action.yml b/.github/actions/pr-metadata/action.yml index de121952a3..05e9c7fb8d 100644 --- a/.github/actions/pr-metadata/action.yml +++ b/.github/actions/pr-metadata/action.yml @@ -18,4 +18,8 @@ runs: - name: Parse Text Metadata id: parse shell: bash - run: echo "metadata=$(go run .github/actions/pr-metadata/re.go \"${{ inputs.text }}\") >> $GITHUB_OUTPUT + run: | + set -ex + body=$(gh pr view --json body --jq '.body') + metadata=$(go run .github/actions/pr-metadata/re.go "$body") + echo "metadata=$metadata >> $GITHUB_OUTPUT diff --git a/.github/workflows/system-tests.yml b/.github/workflows/system-tests.yml index 433138ab13..1090a9cc49 100644 --- a/.github/workflows/system-tests.yml +++ b/.github/workflows/system-tests.yml @@ -116,8 +116,6 @@ jobs: - run: echo ${{ toJSON(github.event) }} - uses: ./binaries/dd-trace-go/.github/actions/pr-metadata - with: - text: ${{ github.event.pull_request.body }} - name: Build weblog run: ./build.sh -i weblog From 8cb0691843528efc240d39d02ae3d26329e44f5e Mon Sep 17 00:00:00 2001 From: Julio Guerra Date: Thu, 4 Apr 2024 16:50:36 +0200 Subject: [PATCH 7/8] ci: composite action --- .github/workflows/system-tests.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/system-tests.yml b/.github/workflows/system-tests.yml index 1090a9cc49..fe16b8a8d3 100644 --- a/.github/workflows/system-tests.yml +++ b/.github/workflows/system-tests.yml @@ -114,7 +114,6 @@ jobs: ref: ${{ inputs.branch_ref || github.ref }} path: 'binaries/dd-trace-go' - - run: echo ${{ toJSON(github.event) }} - uses: ./binaries/dd-trace-go/.github/actions/pr-metadata - name: Build weblog From 6ce6f1fef76681977803b75c8675e58d898375f8 Mon Sep 17 00:00:00 2001 From: Julio Guerra Date: Thu, 4 Apr 2024 16:53:47 +0200 Subject: [PATCH 8/8] ci: composite action --- .github/workflows/system-tests.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/system-tests.yml b/.github/workflows/system-tests.yml index fe16b8a8d3..eff4ffb179 100644 --- a/.github/workflows/system-tests.yml +++ b/.github/workflows/system-tests.yml @@ -115,6 +115,8 @@ jobs: path: 'binaries/dd-trace-go' - uses: ./binaries/dd-trace-go/.github/actions/pr-metadata + env: + GH_TOKEN: ${{ github.token }} - name: Build weblog run: ./build.sh -i weblog