From 5fc06170bdda59d1f11cc426cb10f208612128cc Mon Sep 17 00:00:00 2001 From: chriskarlin Date: Fri, 27 Sep 2024 11:47:46 -0400 Subject: [PATCH 1/9] add skip test flag --- go/build-and-test/action.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/go/build-and-test/action.yml b/go/build-and-test/action.yml index 76d4604..26bdeb3 100644 --- a/go/build-and-test/action.yml +++ b/go/build-and-test/action.yml @@ -36,6 +36,10 @@ inputs: description: A timeout value in seconds. If tests take longer than this, they will fail. Not setting this value will fallback to go test's default of 10 minutes. required: false default: "" + SKIP_TESTS: + description: Skip tests + required: false + default: false runs: using: "composite" @@ -69,6 +73,7 @@ runs: FLIPPCIRCLECIPULLER_REPO_TOKEN: ${{ inputs.FLIPPCIRCLECIPULLER_REPO_TOKEN }} - name: Run custom Go test action uses: wishabi/github-actions/go/test@v0 + if: ${{ !inputs.SKIP_TESTS }} env: DB_HOST: ${{ inputs.DB_HOST }} DB_USER: ${{ inputs.DB_USER }} From 3a82a520ba20bbe96059fde65759345a58bc9cd0 Mon Sep 17 00:00:00 2001 From: chriskarlin Date: Fri, 28 Mar 2025 13:12:04 -0400 Subject: [PATCH 2/9] seperate build from build-and-test --- go/build-and-test/action.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/go/build-and-test/action.yml b/go/build-and-test/action.yml index 26bdeb3..76d4604 100644 --- a/go/build-and-test/action.yml +++ b/go/build-and-test/action.yml @@ -36,10 +36,6 @@ inputs: description: A timeout value in seconds. If tests take longer than this, they will fail. Not setting this value will fallback to go test's default of 10 minutes. required: false default: "" - SKIP_TESTS: - description: Skip tests - required: false - default: false runs: using: "composite" @@ -73,7 +69,6 @@ runs: FLIPPCIRCLECIPULLER_REPO_TOKEN: ${{ inputs.FLIPPCIRCLECIPULLER_REPO_TOKEN }} - name: Run custom Go test action uses: wishabi/github-actions/go/test@v0 - if: ${{ !inputs.SKIP_TESTS }} env: DB_HOST: ${{ inputs.DB_HOST }} DB_USER: ${{ inputs.DB_USER }} From 490677d2fd1e2e7adaabc5e494306485c46c574f Mon Sep 17 00:00:00 2001 From: chriskarlin Date: Fri, 28 Mar 2025 13:12:57 -0400 Subject: [PATCH 3/9] seperate build from build-and-test --- go/build/action.yml | 123 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 go/build/action.yml diff --git a/go/build/action.yml b/go/build/action.yml new file mode 100644 index 0000000..0aac697 --- /dev/null +++ b/go/build/action.yml @@ -0,0 +1,123 @@ +name: "Go Build" +description: "Build go repo" + +inputs: + FLIPPCIRCLECIPULLER_REPO_TOKEN: + description: Flipp circleci repo token + required: true + BUF_BUILD_USER: + description: Buf CI user stored as secret + required: false + BUF_BUILD_API_TOKEN: + description: Buf API token stored as secret + required: false + SLACK_CHANNEL_ID: + description: The Slack channel ID(s) to send the data to + required: false + SLACK_BOT_TOKEN: + description: The Slack bot token to pass the data to + required: false + TIMEOUT: + description: A timeout value in seconds. If tests take longer than this, they will fail. Not setting this value will fallback to go test's default of 10 minutes. + required: false + default: "" + +runs: + using: "composite" + steps: + - name: Set branch variable + id: set-branch + shell: bash + run: | + if [ "${{ github.event_name }}" == "pull_request" ]; then + branch="${{ github.event.pull_request.head.ref }}" + else + branch="${{ github.ref }}" + branch="${branch#refs/heads/}" + fi + echo "branch=${branch}" >> $GITHUB_OUTPUT + - name: Get short sha + id: get-short-sha + run: echo "short_sha=`echo ${GITHUB_SHA::7}`" > $GITHUB_OUTPUT + shell: bash + - name: Configure Go environment + uses: wishabi/github-actions/go/configure@v0 + with: + FLIPPCIRCLECIPULLER_REPO_TOKEN: ${{ inputs.FLIPPCIRCLECIPULLER_REPO_TOKEN }} + BUF_BUILD_USER: ${{ inputs.BUF_BUILD_USER }} + BUF_BUILD_API_TOKEN: ${{ inputs.BUF_BUILD_API_TOKEN }} + - name: Setup Go dependencies + uses: wishabi/github-actions/go/deps@v0 + env: + BUF_TOKEN: ${{ inputs.BUF_BUILD_API_TOKEN }} + with: + FLIPPCIRCLECIPULLER_REPO_TOKEN: ${{ inputs.FLIPPCIRCLECIPULLER_REPO_TOKEN }} + - name: Notify slack channel on failure + if: failure() && inputs.SLACK_CHANNEL_ID != null && github.ref == 'refs/heads/main' + uses: slackapi/slack-github-action@v1.24.0 + env: + SLACK_BOT_TOKEN: ${{ inputs.SLACK_BOT_TOKEN }} + with: + channel-id: ${{ inputs.SLACK_CHANNEL_ID }} + payload: | + { + "text": "Go Build and Test Failed", + "blocks": [ + { + "type": "header", + "text": { + "type": "plain_text", + "text": "Go Build and Test Failed", + "emoji": true + } + }, + { + "type": "divider" + }, + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "*Repository*\n\n\n*${{ github.event_name == 'pull_request' && 'Pull Request' || 'Branch' }}*\n${{ github.event_name == 'pull_request' && format('<{0}|{1}>', github.event.pull_request.html_url, github.event.pull_request.title) || format('', github.repository, github.sha, steps.set-branch.outputs.branch)}}" + }, + "accessory": { + "type": "image", + "image_url": "https://emoji.slack-edge.com/T02AJQYGN/fail/d35657341d0b7dc4.png", + "alt_text": "error icon" + } + }, + { + "type": "divider" + }, + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Version/Commit*" + }, + { + "type": "mrkdwn", + "text": "*Event*" + }, + { + "type": "mrkdwn", + "text": "${{ steps.get-short-sha.outputs.short_sha }}" + }, + { + "type": "mrkdwn", + "text": "${{ github.event_name }}" + } + ] + }, + { + "type": "context", + "elements": [ + { + "type": "mrkdwn", + "text": "*Triggered By:* ${{ github.triggering_actor }}" + } + ] + } + ] + } From b9847c014f2a54dcedc35b9aeca16f5584cc529a Mon Sep 17 00:00:00 2001 From: chriskarlin Date: Fri, 28 Mar 2025 13:14:51 -0400 Subject: [PATCH 4/9] missed this --- go/build/action.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/go/build/action.yml b/go/build/action.yml index 0aac697..363631d 100644 --- a/go/build/action.yml +++ b/go/build/action.yml @@ -17,10 +17,6 @@ inputs: SLACK_BOT_TOKEN: description: The Slack bot token to pass the data to required: false - TIMEOUT: - description: A timeout value in seconds. If tests take longer than this, they will fail. Not setting this value will fallback to go test's default of 10 minutes. - required: false - default: "" runs: using: "composite" @@ -61,13 +57,13 @@ runs: channel-id: ${{ inputs.SLACK_CHANNEL_ID }} payload: | { - "text": "Go Build and Test Failed", + "text": "Go Build Failed", "blocks": [ { "type": "header", "text": { "type": "plain_text", - "text": "Go Build and Test Failed", + "text": "Go Build Failed", "emoji": true } }, From 99d27290e92bcbd6c35f9c4c7cae9f1f25ad44f9 Mon Sep 17 00:00:00 2001 From: chriskarlin Date: Fri, 28 Mar 2025 14:25:16 -0400 Subject: [PATCH 5/9] build-and-test calls build --- go/build-and-test/action.yml | 27 ++++----------------------- 1 file changed, 4 insertions(+), 23 deletions(-) diff --git a/go/build-and-test/action.yml b/go/build-and-test/action.yml index 76d4604..50b312d 100644 --- a/go/build-and-test/action.yml +++ b/go/build-and-test/action.yml @@ -40,31 +40,12 @@ inputs: runs: using: "composite" steps: - - name: Set branch variable - id: set-branch - shell: bash - run: | - if [ "${{ github.event_name }}" == "pull_request" ]; then - branch="${{ github.event.pull_request.head.ref }}" - else - branch="${{ github.ref }}" - branch="${branch#refs/heads/}" - fi - echo "branch=${branch}" >> $GITHUB_OUTPUT - - name: Get short sha - id: get-short-sha - run: echo "short_sha=`echo ${GITHUB_SHA::7}`" > $GITHUB_OUTPUT - shell: bash - - name: Configure Go environment - uses: wishabi/github-actions/go/configure@v0 - with: - FLIPPCIRCLECIPULLER_REPO_TOKEN: ${{ inputs.FLIPPCIRCLECIPULLER_REPO_TOKEN }} - BUF_BUILD_USER: ${{ inputs.BUF_BUILD_USER }} - BUF_BUILD_API_TOKEN: ${{ inputs.BUF_BUILD_API_TOKEN }} - - name: Setup Go dependencies - uses: wishabi/github-actions/go/deps@v0 + - name: Run custom Go build action + uses: wishabi/github-actions/go/build@skip-test env: BUF_TOKEN: ${{ inputs.BUF_BUILD_API_TOKEN }} + BUF_BUILD_USER: ${{ inputs.BUF_BUILD_USER }} + BUF_BUILD_API_TOKEN: ${{ inputs.BUF_BUILD_API_TOKEN }} with: FLIPPCIRCLECIPULLER_REPO_TOKEN: ${{ inputs.FLIPPCIRCLECIPULLER_REPO_TOKEN }} - name: Run custom Go test action From 4bd035134d5dcf302be4008e811a8294dc45051a Mon Sep 17 00:00:00 2001 From: chriskarlin Date: Fri, 28 Mar 2025 14:28:28 -0400 Subject: [PATCH 6/9] need this --- go/build-and-test/action.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/go/build-and-test/action.yml b/go/build-and-test/action.yml index 50b312d..7ba33e5 100644 --- a/go/build-and-test/action.yml +++ b/go/build-and-test/action.yml @@ -40,6 +40,21 @@ inputs: runs: using: "composite" steps: + - name: Set branch variable + id: set-branch + shell: bash + run: | + if [ "${{ github.event_name }}" == "pull_request" ]; then + branch="${{ github.event.pull_request.head.ref }}" + else + branch="${{ github.ref }}" + branch="${branch#refs/heads/}" + fi + echo "branch=${branch}" >> $GITHUB_OUTPUT + - name: Get short sha + id: get-short-sha + run: echo "short_sha=`echo ${GITHUB_SHA::7}`" > $GITHUB_OUTPUT + shell: bash - name: Run custom Go build action uses: wishabi/github-actions/go/build@skip-test env: From cff8c0899322f7897ab75718496264ac585f81f5 Mon Sep 17 00:00:00 2001 From: chriskarlin Date: Fri, 28 Mar 2025 14:37:56 -0400 Subject: [PATCH 7/9] fix --- go/build-and-test/action.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/go/build-and-test/action.yml b/go/build-and-test/action.yml index 7ba33e5..b054f42 100644 --- a/go/build-and-test/action.yml +++ b/go/build-and-test/action.yml @@ -57,12 +57,11 @@ runs: shell: bash - name: Run custom Go build action uses: wishabi/github-actions/go/build@skip-test - env: + with: + FLIPPCIRCLECIPULLER_REPO_TOKEN: ${{ inputs.FLIPPCIRCLECIPULLER_REPO_TOKEN }} BUF_TOKEN: ${{ inputs.BUF_BUILD_API_TOKEN }} BUF_BUILD_USER: ${{ inputs.BUF_BUILD_USER }} BUF_BUILD_API_TOKEN: ${{ inputs.BUF_BUILD_API_TOKEN }} - with: - FLIPPCIRCLECIPULLER_REPO_TOKEN: ${{ inputs.FLIPPCIRCLECIPULLER_REPO_TOKEN }} - name: Run custom Go test action uses: wishabi/github-actions/go/test@v0 env: From 01224d1b28010ff8c53d648df410dd37db0f302e Mon Sep 17 00:00:00 2001 From: chriskarlin Date: Fri, 28 Mar 2025 14:44:24 -0400 Subject: [PATCH 8/9] another fix --- go/build-and-test/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go/build-and-test/action.yml b/go/build-and-test/action.yml index b054f42..0de31f7 100644 --- a/go/build-and-test/action.yml +++ b/go/build-and-test/action.yml @@ -59,7 +59,7 @@ runs: uses: wishabi/github-actions/go/build@skip-test with: FLIPPCIRCLECIPULLER_REPO_TOKEN: ${{ inputs.FLIPPCIRCLECIPULLER_REPO_TOKEN }} - BUF_TOKEN: ${{ inputs.BUF_BUILD_API_TOKEN }} + BUF_BUILD_API_TOKEN: ${{ inputs.BUF_BUILD_API_TOKEN }} BUF_BUILD_USER: ${{ inputs.BUF_BUILD_USER }} BUF_BUILD_API_TOKEN: ${{ inputs.BUF_BUILD_API_TOKEN }} - name: Run custom Go test action From bbf9d05b9a1d97119fcc0839aa7262ef5db54b3a Mon Sep 17 00:00:00 2001 From: chriskarlin Date: Fri, 28 Mar 2025 14:45:42 -0400 Subject: [PATCH 9/9] another fix --- go/build-and-test/action.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/go/build-and-test/action.yml b/go/build-and-test/action.yml index 0de31f7..5d4f41f 100644 --- a/go/build-and-test/action.yml +++ b/go/build-and-test/action.yml @@ -59,7 +59,6 @@ runs: uses: wishabi/github-actions/go/build@skip-test with: FLIPPCIRCLECIPULLER_REPO_TOKEN: ${{ inputs.FLIPPCIRCLECIPULLER_REPO_TOKEN }} - BUF_BUILD_API_TOKEN: ${{ inputs.BUF_BUILD_API_TOKEN }} BUF_BUILD_USER: ${{ inputs.BUF_BUILD_USER }} BUF_BUILD_API_TOKEN: ${{ inputs.BUF_BUILD_API_TOKEN }} - name: Run custom Go test action