diff --git a/.github/actions/setup-nodejs/action.yml b/.github/actions/setup-nodejs/action.yml new file mode 100644 index 0000000..a618b7d --- /dev/null +++ b/.github/actions/setup-nodejs/action.yml @@ -0,0 +1,23 @@ +name: Setup Node.js Environment +description: Setup Node.js with caching and dependency installation +inputs: + working-directory: + description: The working directory of the application that will use this action + required: true + +runs: + using: composite + steps: + # To automatically get bug fixes and new Node.js versions for actions/setup-node, + # change this to (see https://github.com/actions/setup-node#usage): + - name: Set up Node.js + uses: actions/setup-node@v6 + with: + node-version-file: .node-version + - name: Install pnpm + shell: bash + run: corepack enable && corepack prepare pnpm@latest --activate + - name: Install Node.js dependencies + shell: bash + working-directory: ${{ inputs.working-directory }} + run: pnpm install --frozen-lockfile diff --git a/.github/workflows/javascript.yml b/.github/workflows/javascript.yml index 07ff0cc..49826fc 100644 --- a/.github/workflows/javascript.yml +++ b/.github/workflows/javascript.yml @@ -8,42 +8,54 @@ on: branches: - master paths: - - '.github/workflows/javascript.yml' - - '.node-version' - - 'javascript/package.json' - - 'javascript/pnpm-lock.yaml' - - 'javascript/**/*.js' + - .github/workflows/javascript.yml + - .node-version + - javascript/package.json + - javascript/pnpm-lock.yaml + - javascript/pnpm-workspace.yaml + - javascript/**/*.js pull_request: paths: - - '.github/workflows/javascript.yml' - - '.node-version' - - 'javascript/package.json' - - 'javascript/pnpm-lock.yaml' - - 'javascript/**/*.js' + - .github/workflows/javascript.yml + - .node-version + - javascript/package.json + - javascript/pnpm-lock.yaml + - javascript/pnpm-workspace.yaml + - javascript/**/*.js permissions: contents: read + pull-requests: read jobs: - build: - timeout-minutes: 10 + change-detection: runs-on: ubuntu-latest + outputs: + javascript-changes: ${{ steps.change-detection.outputs.javascript }} steps: - uses: actions/checkout@v6 - # https://github.com/actions/setup-node/ - - name: Set up pnpm - uses: pnpm/action-setup@v5 + - name: Change Detection + uses: dorny/paths-filter@v4 + id: change-detection with: - version: 10 - - name: Set up Node.js - uses: actions/setup-node@v4 + filters: | + javascript: + - .github/workflows/javascript.yml + - .node-version + - javascript/package.json + - javascript/pnpm-lock.yaml + - javascript/pnpm-workspace.yaml + - javascript/**/*.js + jest: + timeout-minutes: 10 + runs-on: ubuntu-latest + needs: change-detection + if: needs.change-detection.outputs.javascript-changes == 'true' + steps: + - uses: actions/checkout@v6 + - uses: ./.github/actions/setup-nodejs with: - node-version-file: '.node-version' - cache: 'pnpm' - cache-dependency-path: 'javascript/pnpm-lock.yaml' - - name: Install Packages - working-directory: ./javascript - run: pnpm install --frozen-lockfile - - name: Run Jest + working-directory: ./javascript + - name: Jest working-directory: ./javascript run: pnpm exec jest diff --git a/javascript/pnpm-workspace.yaml b/javascript/pnpm-workspace.yaml index b2a1b32..4fa8bf2 100644 --- a/javascript/pnpm-workspace.yaml +++ b/javascript/pnpm-workspace.yaml @@ -2,7 +2,7 @@ packages: - . allowBuilds: - unrs-resolver: set this to true or false + unrs-resolver: true ignoredBuiltDependencies: - core-js