From 18c0cb32b20c85dc50fcb567307e3f55a949aed9 Mon Sep 17 00:00:00 2001 From: Daniel Kimsey Date: Sat, 15 Apr 2023 15:12:01 -0500 Subject: [PATCH 1/2] Fix MODULE_NOT_FOUND By default the working directory of the composite action is the calling workflows's context. This means a relative require like what was done here isn't reading the action's main.yml. This wasn't caught during testing because GHA requires one to check the testing repo out before being able to run a local action. This masked the behavior. I believe it was missed in the integration tests because those were tested when the main.js was _embedded_ in the action.yml. Hilarious. --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 1073119..a34fb64 100644 --- a/action.yml +++ b/action.yml @@ -45,7 +45,7 @@ runs: with: # github-token: uncomment-this-line-for-local-act-testing script: | - return require('./main.js')({context, core}) + return require(process.env.GITHUB_ACTION_PATH + '/main.js')({context, core}) - name: Send Status uses: slackapi/slack-github-action@007b2c3c751a190b6f0f040e47ed024deaa72844 # v1.23.0 env: From 9afb012e346f8108c2f2ab8e8c6a2cae13b357b3 Mon Sep 17 00:00:00 2001 From: Daniel Kimsey Date: Mon, 17 Apr 2023 08:58:29 -0500 Subject: [PATCH 2/2] Add an on-merge test case --- .github/workflows/test-integration.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .github/workflows/test-integration.yml diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml new file mode 100644 index 0000000..30b852a --- /dev/null +++ b/.github/workflows/test-integration.yml @@ -0,0 +1,26 @@ +# Copyright (c) HashiCorp, Inc. +# SPDX-License-Identifier: MPL-2.0 + +name: test main integration +# This workflow validates the merged code functions exactly as an invoking workflow might use it. +# Due to the requiremnet that `uses` be a hard-coded value, we can only validate explicit git refs. +# In this case, we validate once a PR has been merged, main branch functions correctly + +on: + pull_request: + types: [closed] + +permissions: + contents: read + +jobs: + main-merge: + runs-on: ubuntu-latest + if: github.event.pull_request.merged == true + steps: + - uses: hashicorp/action-slack-status@main + with: + success-message: "Merge successfull" + status: ${{job.status + slack-webhook-url: ${{secrets.slack_webhook_url_feed_releng_test}} +