From 5f2be7297a0659032bd0faf0843c75e6dcbe70b1 Mon Sep 17 00:00:00 2001 From: Daniel Kimsey <90741+dekimsey@users.noreply.github.com> Date: Mon, 17 Apr 2023 10:35:15 -0500 Subject: [PATCH] Fix MODULE_NOT_FOUND (#5) * 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. * Add an on-merge test case --- .github/workflows/test-integration.yml | 26 ++++++++++++++++++++++++++ action.yml | 2 +- 2 files changed, 27 insertions(+), 1 deletion(-) 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}} + 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: