From cca5a70848f3693487018d9eafc4b50e359f652b Mon Sep 17 00:00:00 2001 From: Nick Alteen Date: Thu, 6 Mar 2025 17:22:14 -0500 Subject: [PATCH 1/8] Add action tests to CI workflow --- .github/workflows/continuous-integration.yml | 150 +++++++++++++++++-- 1 file changed, 137 insertions(+), 13 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index f5478d4..fd34c71 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -44,8 +44,8 @@ jobs: id: test run: npm run ci-test - test-templates: - name: Test Actions Templates + test-typescript-npm: + name: Test TypeScript Template (npm) runs-on: ubuntu-latest defaults: @@ -67,6 +67,55 @@ jobs: path: typescript-action repository: actions/typescript-action + - name: Setup Node.js + id: setup-node + uses: actions/setup-node@v4 + with: + node-version-file: local-action/.node-version + cache: npm + cache-dependency-path: local-action/package-lock.json + + - name: Install @github/local-action Dependencies + id: install + run: npm ci + + - name: Install TypeScript Template Dependencies + id: install-typescript + run: npm ci + working-directory: typescript-action + + - name: Link @github/local-action + id: link + run: npm link + + - name: Generate Dotenv File + id: dotenv + run: | + echo "ACTIONS_STEP_DEBUG=true" >> .env + echo "INPUT_MILLISECONDS=2400" >> .env + working-directory: typescript-action + + - name: Test TypeScript Action + id: test-typescript + run: npm run local-action + working-directory: typescript-action + + test-javascript-npm: + name: Test JavaScript Template (npm) + runs-on: ubuntu-latest + + defaults: + run: + shell: bash + working-directory: local-action + + steps: + - name: Checkout @github/local-action + id: checkout + uses: actions/checkout@v4 + with: + path: local-action + - name: Checkout JavaScript Template id: checkout-javascript uses: actions/checkout@v4 @@ -86,11 +135,6 @@ jobs: id: install run: npm ci - - name: Install TypeScript Template Dependencies - id: install-typescript - run: npm ci - working-directory: typescript-action - - name: Install JavaScript Template Dependencies id: install-javascript run: npm ci @@ -105,13 +149,93 @@ jobs: run: | echo "ACTIONS_STEP_DEBUG=true" >> .env echo "INPUT_MILLISECONDS=2400" >> .env - - - name: Test TypeScript Action - id: test-typescript - run: npx @github/local-action . src/main.ts ../local-action/.env - working-directory: typescript-action + working-directory: javascript-action - name: Test JavaScript Action id: test-javascript - run: npx @github/local-action . src/main.js ../local-action/.env + run: npm run local-action working-directory: javascript-action + + test-typescript-pnpm: + name: Test TypeScript Template (pnpm) + runs-on: ubuntu-latest + + defaults: + run: + shell: bash + working-directory: local-action + + steps: + - name: Checkout @github/local-action + id: checkout + uses: actions/checkout@v4 + with: + path: local-action + + - name: Checkout TypeScript Template (ESM) + id: checkout-typescript-esm + uses: actions/checkout@v4 + with: + path: typescript-pnpm-esm-action + repository: ncalteen/typescript-pnpm-esm-action + + - name: Checkout TypeScript Template (CJS) + id: checkout-typescript-cjs + uses: actions/checkout@v4 + with: + path: typescript-pnpm-esm-action + repository: ncalteen/typescript-pnpm-cjs-action + + - name: Install pnpm + id: pnpm + uses: pnpm/action-setup@v4 + + - name: Setup Node.js + id: setup-node + uses: actions/setup-node@v4 + with: + node-version-file: local-action/.node-version + cache: npm + cache-dependency-path: local-action/package-lock.json + + - name: Install @github/local-action Dependencies + id: install + run: npm ci + + - name: Install TypeScript Template Dependencies (ESM) + id: install-typescript-esm + run: pnpm install + working-directory: typescript-pnpm-esm-action + + - name: Install TypeScript Template Dependencies (CJS) + id: install-typescript-cjs + run: pnpm install + working-directory: typescript-pnpm-cjs-action + + - name: Link @github/local-action + id: link + run: pnpm link + + - name: Generate Dotenv File + id: dotenv-esm + run: | + echo "ACTIONS_STEP_DEBUG=true" >> .env + echo "INPUT_MILLISECONDS=2400" >> .env + working-directory: typescript-pnpm-esm-action + + - name: Generate Dotenv File + id: dotenv-cjs + run: | + echo "ACTIONS_STEP_DEBUG=true" >> .env + echo "INPUT_MILLISECONDS=2400" >> .env + working-directory: typescript-pnpm-cjs-action + + - name: Test TypeScript Action (ESM) + id: test-typescript-esm + run: pnpm run local-action + working-directory: typescript-pnpm-esm-action + + - name: Test TypeScript Action (CJS) + id: test-typescript-cjs + run: pnpm run local-action + working-directory: typescript-pnpm-cjs-action From b68f14fd00f3f2de9c29f744735503c9fbe893c6 Mon Sep 17 00:00:00 2001 From: Nick Alteen Date: Thu, 6 Mar 2025 17:22:35 -0500 Subject: [PATCH 2/8] Add trigger --- .github/workflows/continuous-integration.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index fd34c71..5dfe030 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -4,6 +4,7 @@ on: pull_request: branches: - main + workflow_dispatch: {} permissions: actions: read From 32f3a22fa7cc0612ff7d10a63c7d78f5a458e5d5 Mon Sep 17 00:00:00 2001 From: Nick Alteen Date: Thu, 6 Mar 2025 17:24:03 -0500 Subject: [PATCH 3/8] Add latest --- .github/workflows/continuous-integration.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 5dfe030..6ba38e6 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -190,6 +190,8 @@ jobs: - name: Install pnpm id: pnpm uses: pnpm/action-setup@v4 + with: + version: latest - name: Setup Node.js id: setup-node From 21d6fb3b317ed0152753a2bc4ae3652ee2a59756 Mon Sep 17 00:00:00 2001 From: Nick Alteen Date: Thu, 6 Mar 2025 17:25:09 -0500 Subject: [PATCH 4/8] Fix path --- .github/workflows/continuous-integration.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 6ba38e6..61593f1 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -184,7 +184,7 @@ jobs: id: checkout-typescript-cjs uses: actions/checkout@v4 with: - path: typescript-pnpm-esm-action + path: typescript-pnpm-cjs-action repository: ncalteen/typescript-pnpm-cjs-action - name: Install pnpm From 2ceb0499d6ca931d24334e088b31db3ba65aa06c Mon Sep 17 00:00:00 2001 From: Nick Alteen Date: Thu, 6 Mar 2025 21:56:02 -0500 Subject: [PATCH 5/8] Add yarn test --- .github/workflows/continuous-integration.yml | 180 ++++++++++++++----- README.md | 34 +++- 2 files changed, 164 insertions(+), 50 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 61593f1..bf3df39 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -34,7 +34,7 @@ jobs: run: npm ci - name: Check Format - id: format-check + id: format run: npm run format:check - name: Lint @@ -45,15 +45,10 @@ jobs: id: test run: npm run ci-test - test-typescript-npm: - name: Test TypeScript Template (npm) + test-typescript-esm-npm: + name: Test TypeScript ESM Template (npm) runs-on: ubuntu-latest - defaults: - run: - shell: bash - working-directory: local-action - steps: - name: Checkout @github/local-action id: checkout @@ -79,6 +74,7 @@ jobs: - name: Install @github/local-action Dependencies id: install run: npm ci + working-directory: local-action - name: Install TypeScript Template Dependencies id: install-typescript @@ -88,6 +84,7 @@ jobs: - name: Link @github/local-action id: link run: npm link + working-directory: local-action - name: Generate Dotenv File id: dotenv @@ -97,19 +94,14 @@ jobs: working-directory: typescript-action - name: Test TypeScript Action - id: test-typescript + id: test run: npm run local-action working-directory: typescript-action - test-javascript-npm: - name: Test JavaScript Template (npm) + test-javascript-esm-npm: + name: Test JavaScript ESM Template (npm) runs-on: ubuntu-latest - defaults: - run: - shell: bash - working-directory: local-action - steps: - name: Checkout @github/local-action id: checkout @@ -135,6 +127,7 @@ jobs: - name: Install @github/local-action Dependencies id: install run: npm ci + working-directory: local-action - name: Install JavaScript Template Dependencies id: install-javascript @@ -144,6 +137,7 @@ jobs: - name: Link @github/local-action id: link run: npm link + working-directory: local-action - name: Generate Dotenv File id: dotenv @@ -153,19 +147,14 @@ jobs: working-directory: javascript-action - name: Test JavaScript Action - id: test-javascript + id: test run: npm run local-action working-directory: javascript-action - test-typescript-pnpm: - name: Test TypeScript Template (pnpm) + test-typescript-esm-pnpm: + name: Test TypeScript ESM Template (pnpm) runs-on: ubuntu-latest - defaults: - run: - shell: bash - working-directory: local-action - steps: - name: Checkout @github/local-action id: checkout @@ -173,15 +162,67 @@ jobs: with: path: local-action - - name: Checkout TypeScript Template (ESM) - id: checkout-typescript-esm + - name: Checkout TypeScript Template + id: checkout-typescript uses: actions/checkout@v4 with: path: typescript-pnpm-esm-action repository: ncalteen/typescript-pnpm-esm-action - - name: Checkout TypeScript Template (CJS) - id: checkout-typescript-cjs + - name: Install pnpm + id: pnpm + uses: pnpm/action-setup@v4 + with: + version: latest + + - name: Setup Node.js + id: setup-node + uses: actions/setup-node@v4 + with: + node-version-file: local-action/.node-version + cache: npm + cache-dependency-path: local-action/package-lock.json + + - name: Install @github/local-action Dependencies + id: install + run: npm ci + working-directory: local-action + + - name: Install TypeScript Template Dependencies + id: install-typescript + run: pnpm install + working-directory: typescript-pnpm-esm-action + + - name: Link @github/local-action + id: link + run: pnpm link + working-directory: local-action + + - name: Generate Dotenv File + id: dotenv + run: | + echo "ACTIONS_STEP_DEBUG=true" >> .env + echo "INPUT_MILLISECONDS=2400" >> .env + working-directory: typescript-pnpm-esm-action + + - name: Test TypeScript Action + id: test + run: pnpm run local-action + working-directory: typescript-pnpm-esm-action + + test-typescript-cjs-pnpm: + name: Test TypeScript CJS Template (pnpm) + runs-on: ubuntu-latest + + steps: + - name: Checkout @github/local-action + id: checkout + uses: actions/checkout@v4 + with: + path: local-action + + - name: Checkout TypeScript Template + id: checkout-typescript uses: actions/checkout@v4 with: path: typescript-pnpm-cjs-action @@ -204,41 +245,84 @@ jobs: - name: Install @github/local-action Dependencies id: install run: npm ci + working-directory: local-action - - name: Install TypeScript Template Dependencies (ESM) - id: install-typescript-esm - run: pnpm install - working-directory: typescript-pnpm-esm-action - - - name: Install TypeScript Template Dependencies (CJS) - id: install-typescript-cjs + - name: Install TypeScript Template Dependencies + id: install-typescript run: pnpm install working-directory: typescript-pnpm-cjs-action - name: Link @github/local-action id: link run: pnpm link + working-directory: local-action - name: Generate Dotenv File - id: dotenv-esm + id: dotenv run: | echo "ACTIONS_STEP_DEBUG=true" >> .env echo "INPUT_MILLISECONDS=2400" >> .env - working-directory: typescript-pnpm-esm-action + working-directory: typescript-pnpm-cjs-action + + - name: Test TypeScript Action + id: test + run: pnpm run local-action + working-directory: typescript-pnpm-cjs-action + + test-typescript-esm-yarn: + name: Test TypeScript ESM Template (yarn) + runs-on: ubuntu-latest + + defaults: + run: + shell: bash + working-directory: local-action + + steps: + - name: Checkout @github/local-action + id: checkout + uses: actions/checkout@v4 + with: + path: local-action + + - name: Checkout TypeScript Template + id: checkout-typescript + uses: actions/checkout@v4 + with: + path: typescript-yarn-esm-action + repository: ncalteen/typescript-yarn-esm-action + + - name: Setup Node.js + id: setup-node + uses: actions/setup-node@v4 + with: + node-version-file: local-action/.node-version + cache: npm + cache-dependency-path: local-action/package-lock.json + + - name: Install @github/local-action Dependencies + id: install + run: npm ci + working-directory: local-action + + - name: Install TypeScript Template Dependencies + id: install-typescript + run: yarn install + working-directory: typescript-yarn-esm-action + + - name: Link @github/local-action + id: link + run: yarn link + working-directory: local-action - name: Generate Dotenv File - id: dotenv-cjs + id: dotenv run: | echo "ACTIONS_STEP_DEBUG=true" >> .env echo "INPUT_MILLISECONDS=2400" >> .env - working-directory: typescript-pnpm-cjs-action - - - name: Test TypeScript Action (ESM) - id: test-typescript-esm - run: pnpm run local-action - working-directory: typescript-pnpm-esm-action + working-directory: typescript-yarn-esm-action - - name: Test TypeScript Action (CJS) - id: test-typescript-cjs - run: pnpm run local-action - working-directory: typescript-pnpm-cjs-action + - name: Test TypeScript Action + id: test-typescript + run: yarn run local-action + working-directory: typescript-yarn-esm-action diff --git a/README.md b/README.md index 3fc87e6..2513f32 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,35 @@ currently implemented by this tool. See the [CHANGELOG](./CHANGELOG.md) for a complete list of changes. +## Package Manager Support + +### `npm` Support + +This tool is designed primarily for use with `npm` and `npx`. It is recommended +to use `npm` for managing actions you wish to test with this tool. + +### `pnpm` Support + +This tool ships with **experimental** support for `pnpm`. If you encounter any +issues, please file an issue +[here](https://github.com/github/local-action/issues). + +Some caveats to this support are listed below. + +- This tool does not support CommonJS actions using `pnpm`. + +## `yarn` Support + +This tool ships with **experimental** support for `pnpm`. If you encounter any +issues, please file an issue +[here](https://github.com/github/local-action/issues). + +Some caveats to this support are listed below. + +- The `@github/local-action` package should be run using + `yarn dlx @github/local-action` instead of `yarn local-action`. +- This tool does not support CommonJS actions using `yarn`. + ## Prerequisites ### Installed Tools @@ -83,8 +112,9 @@ the following when preparing for release: - Commit the `node_modules` directory to your repository - Transpile your code and dependencies using tools like - [`tsc`](https://www.typescriptlang.org/docs/handbook/compiler-options.html) or - [`@vercel/ncc`](https://www.npmjs.com/package/@vercel/ncc) + [`tsc`](https://www.typescriptlang.org/docs/handbook/compiler-options.html), + [`@vercel/ncc`](https://www.npmjs.com/package/@vercel/ncc), or + [`rollup`](https://rollupjs.org/) **This tool supports non-transpiled action code only.** This is because it uses [`quibble`](https://github.com/testdouble/quibble) to override GitHub Actions From 084623f88dd3fb088cb2331c076cbe19dc610be4 Mon Sep 17 00:00:00 2001 From: Nick Alteen Date: Thu, 6 Mar 2025 22:00:03 -0500 Subject: [PATCH 6/8] Set yarn version --- .github/workflows/continuous-integration.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index bf3df39..f9de7ec 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -292,6 +292,13 @@ jobs: path: typescript-yarn-esm-action repository: ncalteen/typescript-yarn-esm-action + - name: Set Yarn version + id: set-yarn + run: | + corepack enable + yarn set version stable + working-directory: typescript-yarn-esm-action + - name: Setup Node.js id: setup-node uses: actions/setup-node@v4 From af8b82d12fdbc44e9938fd2e78dac9b6ebb21274 Mon Sep 17 00:00:00 2001 From: Nick Alteen Date: Thu, 6 Mar 2025 22:02:40 -0500 Subject: [PATCH 7/8] Fix name --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2513f32..755a588 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ Some caveats to this support are listed below. ## `yarn` Support -This tool ships with **experimental** support for `pnpm`. If you encounter any +This tool ships with **experimental** support for `yarn`. If you encounter any issues, please file an issue [here](https://github.com/github/local-action/issues). From 073808771e59f874bc3b676b8aed828ae8ca509a Mon Sep 17 00:00:00 2001 From: Nick Alteen Date: Tue, 11 Mar 2025 12:07:13 -0400 Subject: [PATCH 8/8] Fix check for package.json path --- badges/coverage.svg | 2 +- package-lock.json | 4 ++-- package.json | 2 +- src/commands/run.ts | 10 +++++++--- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/badges/coverage.svg b/badges/coverage.svg index 5bb55be..1b3eb31 100644 --- a/badges/coverage.svg +++ b/badges/coverage.svg @@ -1 +1 @@ -Coverage: 100%Coverage100% \ No newline at end of file +Coverage: 100%Coverage100% \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 9a1a089..089844f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@github/local-action", - "version": "3.1.0", + "version": "3.1.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@github/local-action", - "version": "3.1.0", + "version": "3.1.1", "license": "MIT", "dependencies": { "@actions/artifact": "^2.2.0", diff --git a/package.json b/package.json index ab251a2..04f2d1d 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@github/local-action", "description": "Local Debugging for GitHub Actions", - "version": "3.1.0", + "version": "3.1.1", "type": "module", "author": "Nick Alteen ", "private": false, diff --git a/src/commands/run.ts b/src/commands/run.ts index 9f71669..b1d5275 100644 --- a/src/commands/run.ts +++ b/src/commands/run.ts @@ -119,19 +119,23 @@ export async function action(): Promise { // Starting at the target action's entrypoint, find the package.json file. const dirs = path.dirname(EnvMeta.entrypoint).split(path.sep) let packageJsonPath + let found = false // Move up the directory tree until we find a package.json directory. while (dirs.length > 0) { - packageJsonPath = path.join(process.env.TARGET_ACTION_PATH!, 'package.json') + packageJsonPath = path.resolve(dirs.join(path.sep), 'package.json') // Check if the current directory has a package.json file. - if (fs.existsSync(packageJsonPath)) break + if (fs.existsSync(packageJsonPath)) { + found = true + break + } // Move up the directory tree. dirs.pop() } - if (dirs.length === 0 || !packageJsonPath) + if (!found || !packageJsonPath) throw new Error( 'No package.json file found in the action directory or any parent directories.' ) pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy