diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index f5478d4..f9de7ec 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 @@ -33,7 +34,7 @@ jobs: run: npm ci - name: Check Format - id: format-check + id: format run: npm run format:check - name: Lint @@ -44,15 +45,10 @@ jobs: id: test run: npm run ci-test - test-templates: - name: Test Actions Templates + 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 @@ -67,6 +63,52 @@ 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 + working-directory: local-action + + - 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 + 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-action + + - name: Test TypeScript Action + id: test + run: npm run local-action + working-directory: typescript-action + + test-javascript-esm-npm: + name: Test JavaScript ESM Template (npm) + runs-on: ubuntu-latest + + 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 @@ -85,11 +127,7 @@ jobs: - 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 + working-directory: local-action - name: Install JavaScript Template Dependencies id: install-javascript @@ -99,19 +137,199 @@ jobs: - name: Link @github/local-action id: link run: npm link + working-directory: local-action - name: Generate Dotenv File id: dotenv 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 + id: test + run: npm run local-action working-directory: javascript-action + + test-typescript-esm-pnpm: + name: Test TypeScript ESM 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-esm-action + repository: ncalteen/typescript-pnpm-esm-action + + - 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 + repository: ncalteen/typescript-pnpm-cjs-action + + - 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-cjs-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-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: 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 + 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 + run: | + echo "ACTIONS_STEP_DEBUG=true" >> .env + echo "INPUT_MILLISECONDS=2400" >> .env + working-directory: typescript-yarn-esm-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..755a588 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 `yarn`. 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 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