diff --git a/.github/workflows/autobahn.yml b/.github/workflows/autobahn.yml index 449523705dc..c76381765b8 100644 --- a/.github/workflows/autobahn.yml +++ b/.github/workflows/autobahn.yml @@ -5,7 +5,7 @@ on: workflow_call: inputs: node-version: - default: '22' + default: '24' type: string pull_request: paths: @@ -19,7 +19,7 @@ jobs: autobahn: name: Autobahn Test Suite runs-on: ubuntu-latest - container: node:22 + container: node:24 services: fuzzingserver: image: crossbario/autobahn-testsuite:latest @@ -30,7 +30,7 @@ jobs: - ${{ github.workspace }}/test/autobahn/config:/config - ${{ github.workspace }}/test/autobahn/reports:/reports steps: - - name: Checkout Code + - name: Checkout Repository uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 with: persist-credentials: false @@ -42,10 +42,10 @@ jobs: with: args: docker restart --time 0 --signal=SIGKILL fuzzingserver - - name: Setup Node.js@${{ inputs.node-version || '22' }} + - name: Setup Node.js@${{ inputs.node-version }} uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 with: - node-version: ${{ inputs.node-version || '22' }} + node-version: ${{ inputs.node-version }} - name: Run Autobahn Test Suite run: npm run test:websocket:autobahn diff --git a/.github/workflows/backport.yml b/.github/workflows/backport.yml index 4621cf7e510..22586651256 100644 --- a/.github/workflows/backport.yml +++ b/.github/workflows/backport.yml @@ -24,6 +24,7 @@ jobs: name: Backport steps: - name: Backport - uses: tibdex/backport@v2 + uses: tibdex/backport@9565281eda0731b1d20c4025c43339fb0a23812e # v2.0.4 + id: backport with: github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/bench.yml b/.github/workflows/bench.yml index efb6a54b132..4309139a663 100644 --- a/.github/workflows/bench.yml +++ b/.github/workflows/bench.yml @@ -11,7 +11,7 @@ jobs: name: benchmark current runs-on: ubuntu-latest steps: - - name: Checkout Code + - name: Checkout Repository uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 with: persist-credentials: false @@ -19,7 +19,7 @@ jobs: - name: Setup Node uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 with: - node-version: lts/* + node-version: 'lts/*' - name: Install Modules for undici run: npm i --ignore-scripts --omit=dev - name: Install Modules for Benchmarks @@ -33,14 +33,14 @@ jobs: name: benchmark branch runs-on: ubuntu-latest steps: - - name: Checkout Code + - name: Checkout Repository uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 with: persist-credentials: false - name: Setup Node uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 with: - node-version: lts/* + node-version: 'lts/*' - name: Install Modules for undici run: npm i --ignore-scripts --omit=dev - name: Install Modules for Benchmarks @@ -54,7 +54,7 @@ jobs: name: benchmark (sending data) current runs-on: ubuntu-latest steps: - - name: Checkout Code + - name: Checkout Repository uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 with: persist-credentials: false @@ -62,7 +62,7 @@ jobs: - name: Setup Node uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 with: - node-version: lts/* + node-version: 'lts/*' - name: Install Modules for undici run: npm i --ignore-scripts --omit=dev - name: Install Modules for Benchmarks @@ -76,14 +76,14 @@ jobs: name: benchmark (sending data) branch runs-on: ubuntu-latest steps: - - name: Checkout Code + - name: Checkout Repository uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 with: persist-credentials: false - name: Setup Node uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 with: - node-version: lts/* + node-version: 'lts/*' - name: Install Modules for undici run: npm i --ignore-scripts --omit=dev - name: Install Modules for Benchmarks @@ -97,7 +97,7 @@ jobs: name: benchmark current h2 runs-on: ubuntu-latest steps: - - name: Checkout Code + - name: Checkout Repository uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 with: persist-credentials: false @@ -105,7 +105,7 @@ jobs: - name: Setup Node uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 with: - node-version: lts/* + node-version: 'lts/*' - name: Install Modules for undici run: npm i --ignore-scripts --omit=dev - name: Install Modules for Benchmarks @@ -119,14 +119,14 @@ jobs: name: benchmark branch h2 runs-on: ubuntu-latest steps: - - name: Checkout Code + - name: Checkout Repository uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 with: persist-credentials: false - name: Setup Node uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 with: - node-version: lts/* + node-version: 'lts/*' - name: Install Modules for undici run: npm i --ignore-scripts --omit=dev - name: Install Modules for Benchmarks diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000000..b3c2f41c7f6 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,236 @@ +name: CI + +on: + push: + branches: + - main + - current + - next + - 'v*' + pull_request: + +permissions: + contents: read + +jobs: + dependency-review: + if: ${{ github.event_name == 'pull_request' }} + runs-on: ubuntu-latest + steps: + - name: Harden Runner + uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0 + with: + egress-policy: audit + + - name: Checkout Repository + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 + with: + persist-credentials: false + + - name: Dependency Review + uses: actions/dependency-review-action@595b5aeba73380359d98a5e087f648dbb0edce1b # v4.7.3 + + lint: + name: Lint + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 + with: + persist-credentials: false + + - name: Setup Node.js + uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 + with: + node-version: 'lts/*' + + - name: Install dependencies + run: npm install + + - name: Lint + run: npm run lint + + test: + strategy: + fail-fast: false + max-parallel: 0 + matrix: + node-version: ['20', '22', '24'] + runs-on: ['ubuntu-latest', 'windows-latest', 'macos-latest'] + exclude: + - node-version: '20' + runs-on: windows-latest + uses: ./.github/workflows/nodejs.yml + with: + codecov: ${{ matrix.node-version == '24' && matrix.runs-on == 'ubuntu-latest' }} + node-version: ${{ matrix.node-version }} + runs-on: ${{ matrix.runs-on }} + secrets: inherit + + test-without-intl: + name: Test with Node.js ${{ matrix.node-version }} compiled --without-intl + strategy: + fail-fast: false + max-parallel: 0 + matrix: + node-version: ['20', '22', '24'] + runs-on: ubuntu-latest + timeout-minutes: 120 + steps: + - name: Checkout Repository + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 + with: + persist-credentials: false + submodules: recursive + + # Setup node, install deps, and build undici prior to building icu-less node and testing + - name: Setup Node.js@${{ matrix.node-version }} + uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 + with: + node-version: ${{ matrix.node-version }} + + - name: Install dependencies + run: npm install + + - name: Build undici + run: npm run build:node + + - name: Determine latest release + id: release + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 + with: + result-encoding: string + script: | + const req = await fetch('https://nodejs.org/download/release/index.json') + const releases = await req.json() + + const latest = releases.find((r) => r.version.startsWith('v${{ matrix.node-version }}')) + return latest.version + + - name: Download and extract source + run: curl https://nodejs.org/download/release/${{ steps.release.outputs.result }}/node-${{ steps.release.outputs.result }}.tar.xz | tar xfJ - + + - name: Install ninja + run: sudo apt-get install ninja-build + + - name: ccache + uses: hendrikmuhs/ccache-action@63069e3931dedbf3b63792097479563182fe70d1 #v1.2.18 + with: + key: node${{ matrix.node-version }} + + - name: Build node + working-directory: ./node-${{ steps.release.outputs.result }} + run: | + export CC="ccache gcc" + export CXX="ccache g++" + ./configure --without-intl --ninja --prefix=./final + make + make install + echo "$(pwd)/final/bin" >> $GITHUB_PATH + + - name: Print version information + run: | + echo OS: $(node -p "os.version()") + echo Node.js: $(node --version) + echo "Node.js built-in dependencies: $(node -p "'\r\n' + (Object.entries(process.versions).map(([k, v], i, arr) => (i !== arr.length - 1 ? '├──' : '└──') + k + '@' + v)).join('\r\n')")" + echo npm: $(npm --version) + echo git: $(git --version) + echo icu config: $(node -e "console.log(process.config)" | grep icu) + + - name: Configure hosts file for WPT (Windows) + if: runner.os == 'Windows' + run: | + cd ${{ github.workspace }}\test\web-platform-tests\wpt + python wpt make-hosts-file | Out-File $env:SystemRoot\System32\drivers\etc\hosts -Encoding ascii -Append + shell: powershell + + - name: Configure hosts file for WPT (Unix) + if: runner.os != 'Windows' + run: | + cd ${{ github.workspace }}/test/web-platform-tests/wpt + python3 wpt make-hosts-file | sudo tee -a /etc/hosts + + - name: Run tests + run: npm run test:javascript:without-intl + + test-fuzzing: + name: Fuzzing + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 + with: + persist-credentials: false + + - name: Setup Node.js + uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 + with: + node-version: lts/* + + - name: Install dependencies + run: npm install + + - name: Run fuzzing tests + run: npm run test:fuzzing + + test-types: + name: Test TypeScript types + timeout-minutes: 15 + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 + with: + persist-credentials: false + + - name: Setup Node.js + uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 + with: + node-version: lts/* + + - name: Install dependencies + run: npm install + + - name: Run typings tests + run: npm run test:typescript + + test-sqlite: + name: Test with SQLite enabled + timeout-minutes: 15 + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 + with: + persist-credentials: false + + - name: Setup Node.js + uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 + with: + node-version: '24' + + - name: Install dependencies + run: npm install + + - name: Run typings tests + run: npm run test:sqlite + + automerge: + if: > + github.event_name == 'pull_request' && github.event.pull_request.user.login == 'dependabot[bot]' + needs: + - dependency-review + - test + - test-types + - test-without-intl + - test-fuzzing + - lint + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + steps: + - name: Merge Dependabot PR + uses: fastify/github-action-merge-dependabot@e820d631adb1d8ab16c3b93e5afe713450884a4a # v3.11.1 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index e8e321fcfa6..691bf4bed90 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -47,6 +47,8 @@ jobs: - name: Checkout repository uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 + with: + persist-credentials: false # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL diff --git a/.github/workflows/nightly.yml b/.github/workflows/nodejs-nightly.yml similarity index 63% rename from .github/workflows/nightly.yml rename to .github/workflows/nodejs-nightly.yml index 7da843a9e6e..cda46a88d87 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nodejs-nightly.yml @@ -1,4 +1,4 @@ -name: Nightly tests +name: Node.js Nightly on: workflow_dispatch: @@ -9,44 +9,33 @@ permissions: contents: read jobs: - test-linux: + test: + name: Test with Node.js ${{ matrix.node-version }} on ${{ matrix.runs-on }} if: github.repository == 'nodejs/undici' - uses: ./.github/workflows/test.yml + strategy: + fail-fast: false + max-parallel: 0 + matrix: + node-version: ['25-nightly'] + runs-on: [ubuntu-latest, windows-latest, macos-latest] + uses: ./.github/workflows/nodejs.yml with: - node-version: 23-nightly - runs-on: ubuntu-latest + node-version: ${{ matrix.node-version }} + runs-on: ${{ matrix.runs-on }} secrets: inherit - test-autobahn: + autobahn: if: github.repository == 'nodejs/undici' uses: ./.github/workflows/autobahn.yml with: - node-version: 23-nightly - secrets: inherit - - test-windows: - if: github.repository == 'nodejs/undici' - uses: ./.github/workflows/test.yml - with: - node-version: 23-nightly - runs-on: windows-latest - secrets: inherit - - test-macos: - if: github.repository == 'nodejs/undici' - uses: ./.github/workflows/test.yml - with: - node-version: 23-nightly - runs-on: macos-latest + node-version: '25-nightly' secrets: inherit report-failure: - if: ${{ always() && (needs.test-linux.result == 'failure' && needs.test-windows.result == 'failure' && needs.test-macos.result == 'failure') }} + if: ${{ always() && (needs.test.result == 'failure' || needs.autobahn.result == 'failure') }} needs: - - test-linux - - test-windows - - test-macos - - test-autobahn + - test + - autobahn runs-on: ubuntu-latest permissions: issues: write diff --git a/.github/workflows/nodejs-shared.yml b/.github/workflows/nodejs-shared.yml index 14044a2a655..a58c3ccda25 100644 --- a/.github/workflows/nodejs-shared.yml +++ b/.github/workflows/nodejs-shared.yml @@ -14,27 +14,27 @@ permissions: jobs: test-shared-builtin: - name: Test with Node.js ${{ matrix.version }} compiled --shared-builtin-undici/undici-path + name: Test with Node.js ${{ matrix.node-version }} compiled --shared-builtin-undici/undici-path strategy: fail-fast: false max-parallel: 0 matrix: - version: [20, 22, 24] + node-version: ['20', '22', '24'] runs-on: ubuntu-latest timeout-minutes: 120 steps: # Checkout into a subdirectory otherwise Node.js tests will break due to finding Undici's package.json in a parent directory. - - name: Checkout + - name: Checkout Repository uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 with: path: ./undici persist-credentials: false # Setup node, install deps, and build undici prior to building node with `--shared-builtin-undici/undici-path` and testing - - name: Setup Node.js@${{ inputs.version }} + - name: Setup Node.js@${{ matrix.node-version }} uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 with: - node-version: ${{ inputs.version }} + node-version: ${{ matrix.node-version }} - name: Install dependencies working-directory: ./undici @@ -62,7 +62,7 @@ jobs: const req = await fetch('https://nodejs.org/download/release/index.json') const releases = await req.json() - const latest = releases.find((r) => r.version.startsWith('v${{ matrix.version }}')) + const latest = releases.find((r) => r.version.startsWith('v${{ matrix.node-version }}')) return latest.version - name: Download and extract source @@ -74,7 +74,7 @@ jobs: - name: ccache uses: hendrikmuhs/ccache-action@63069e3931dedbf3b63792097479563182fe70d1 #v1.2.18 with: - key: node(external_undici)${{ matrix.version }} + key: node(external_undici)${{ matrix.node-version }} - name: Build node working-directory: ./node-${{ steps.release.outputs.result }} @@ -91,6 +91,7 @@ jobs: run: | echo OS: $(node -p "os.version()") echo Node.js: $(node --version) + echo "Node.js built-in dependencies: $(node -p "'\r\n' + (Object.entries(process.versions).map(([k, v], i, arr) => (i !== arr.length - 1 ? '├──' : '└──') + k + '@' + v)).join('\r\n')")" echo npm: $(npm --version) echo git: $(git --version) echo external config: $(node -e "console.log(process.config)" | grep NODE_SHARED_BUILTIN_UNDICI_UNDICI_PATH) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index a362a05bbe2..b8eb890c5f0 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -1,145 +1,53 @@ -name: Node CI +name: Node.js on: - push: - branches: - - main - - current - - next - - 'v*' - pull_request: + workflow_call: + inputs: + node-version: + required: true + type: string + runs-on: + required: true + type: string + codecov: + required: false + type: boolean + default: false permissions: contents: read jobs: - dependency-review: - if: ${{ github.event_name == 'pull_request' }} - runs-on: ubuntu-latest - steps: - - name: Harden Runner - uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0 - with: - egress-policy: audit - - - name: Checkout - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 - with: - persist-credentials: false - - - name: Dependency Review - uses: actions/dependency-review-action@595b5aeba73380359d98a5e087f648dbb0edce1b # v4.7.3 - - lint: - name: Lint - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 - with: - persist-credentials: false - - - name: Setup Node.js - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 - with: - node-version: lts/* - - - name: Install dependencies - run: npm install - - - name: Lint - run: npm run lint - test: - strategy: - fail-fast: false - max-parallel: 0 - matrix: - node-version: - - 20 - - 22 - - 24 - runs-on: - - ubuntu-latest - - windows-latest - - macos-latest - exclude: - - node-version: 20 - runs-on: windows-latest - uses: ./.github/workflows/test.yml - with: - node-version: ${{ matrix.node-version }} - runs-on: ${{ matrix.runs-on }} - secrets: inherit - - test-without-intl: - name: Test with Node.js ${{ matrix.version }} compiled --without-intl - strategy: - fail-fast: false - max-parallel: 0 - matrix: - version: [20, 22, 24] - runs-on: ubuntu-latest - timeout-minutes: 120 + name: Test with Node.js ${{ inputs.node-version }} on ${{ inputs.runs-on }} + timeout-minutes: 15 + runs-on: ${{ inputs.runs-on }} steps: - - name: Checkout + - name: Checkout Repository uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 with: persist-credentials: false submodules: recursive - # Setup node, install deps, and build undici prior to building icu-less node and testing - - name: Setup Node.js@${{ inputs.version }} + - name: Setup Node.js@${{ inputs.node-version }} uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 with: - node-version: ${{ inputs.version }} - - - name: Install dependencies - run: npm install - - - name: Build undici - run: npm run build:node - - - name: Determine latest release - id: release - uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 - with: - result-encoding: string - script: | - const req = await fetch('https://nodejs.org/download/release/index.json') - const releases = await req.json() - - const latest = releases.find((r) => r.version.startsWith('v${{ matrix.version }}')) - return latest.version - - - name: Download and extract source - run: curl https://nodejs.org/download/release/${{ steps.release.outputs.result }}/node-${{ steps.release.outputs.result }}.tar.xz | tar xfJ - - - - name: Install ninja - run: sudo apt-get install ninja-build - - - name: ccache - uses: hendrikmuhs/ccache-action@63069e3931dedbf3b63792097479563182fe70d1 #v1.2.18 - with: - key: node${{ matrix.version }} - - - name: Build node - working-directory: ./node-${{ steps.release.outputs.result }} - run: | - export CC="ccache gcc" - export CXX="ccache g++" - ./configure --without-intl --ninja --prefix=./final - make - make install - echo "$(pwd)/final/bin" >> $GITHUB_PATH + node-version: ${{ inputs.node-version }} - name: Print version information run: | echo OS: $(node -p "os.version()") echo Node.js: $(node --version) + echo "Node.js built-in dependencies: $(node -p "'\r\n' + (Object.entries(process.versions).map(([k, v], i, arr) => (i !== arr.length - 1 ? '├──' : '└──') + k + '@' + v)).join('\r\n')")" echo npm: $(npm --version) echo git: $(git --version) - echo icu config: $(node -e "console.log(process.config)" | grep icu) + + - name: Install dependencies + run: npm install + + - name: Print installed dependencies + run: npm ls --all + continue-on-error: true - name: Configure hosts file for WPT (Windows) if: runner.os == 'Windows' @@ -154,87 +62,22 @@ jobs: cd ${{ github.workspace }}/test/web-platform-tests/wpt python3 wpt make-hosts-file | sudo tee -a /etc/hosts - - name: Run tests - run: npm run test:javascript:without-intl - - test-fuzzing: - name: Fuzzing - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 - with: - persist-credentials: false - - - name: Setup Node.js - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 - with: - node-version: lts/* - - - name: Install dependencies - run: npm install - - - name: Run fuzzing tests - run: npm run test:fuzzing - - test-types: - name: Test TypeScript types - timeout-minutes: 15 - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 - with: - persist-credentials: false - - - name: Setup Node.js - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 - with: - node-version: lts/* - - - name: Install dependencies - run: npm install - - - name: Run typings tests - run: npm run test:typescript - - test-sqlite: - name: Test with SQLite enabled - timeout-minutes: 15 - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 - with: - persist-credentials: false - - - name: Setup Node.js - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 - with: - node-version: 22 - - - name: Install dependencies - run: npm install - - - name: Run typings tests - run: npm run test:sqlite + - name: Run tests with coverage + id: coverage + if: inputs.codecov == true + run: npm run coverage:ci + env: + CI: true + NODE_V8_COVERAGE: ./coverage/tmp - automerge: - if: > - github.event_name == 'pull_request' && github.event.pull_request.user.login == 'dependabot[bot]' - needs: - - dependency-review - - test - - test-types - - test-without-intl - - test-fuzzing - - lint - runs-on: ubuntu-latest - permissions: - contents: write - pull-requests: write - steps: - - name: Merge Dependabot PR - uses: fastify/github-action-merge-dependabot@e820d631adb1d8ab16c3b93e5afe713450884a4a # v3.11.1 + - name: Run tests + if: inputs.codecov != true + run: npm run test:javascript + env: + CI: true + + - name: Coverage Report + if: inputs.codecov == true + uses: codecov/codecov-action@fdcc8476540edceab3de004e990f80d881c6cc00 # v5.5.0 with: - github-token: ${{ secrets.GITHUB_TOKEN }} + token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/release-create-pr.yml b/.github/workflows/release-create-pr.yml index f61bda23076..0a4a697a251 100644 --- a/.github/workflows/release-create-pr.yml +++ b/.github/workflows/release-create-pr.yml @@ -30,14 +30,23 @@ jobs: version: ${{ steps.bump.outputs.version }} steps: - - uses: actions/checkout@v5 - - uses: actions/setup-node@v4 + - name: Checkout Repository + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 + id: checkout with: - node-version: '20' + persist-credentials: true + + - name: Setup Node.js + uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 + id: setup-node + with: + node-version: 'lts/*' - name: Git Config + id: git-config run: | git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" git config --global user.name "github-actions[bot]" + - name: Change version number and push id: bump run: | @@ -48,8 +57,10 @@ jobs: git commit -m "Bumped v$VERSION" git push origin "HEAD:$RELEASE_BRANCH" echo "version=$VERSION" >> $GITHUB_OUTPUT + - name: Create PR - uses: actions/github-script@v7 + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 + id: create-pr with: script: | const defaultBranch = "${{ github.event.repository.default_branch }}" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bc62816e90b..29f8db5b487 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,4 @@ -name: Create release +name: Release undici and undici-types on NPM and create GitHub Release on: push: @@ -11,14 +11,19 @@ permissions: contents: read jobs: - check-release-version: + determine-release-version: runs-on: ubuntu-latest outputs: - release-version: ${{ steps.set-release-version.outputs.result }} + release-version: ${{ steps.determine-release-version.outputs.result }} steps: - - uses: actions/checkout@v5 - - uses: actions/github-script@v7 - id: set-release-version + - name: Checkout Repository + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 + id: checkout + with: + persist-credentials: false + - name: Determine release version + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 + id: determine-release-version with: result-encoding: string script: | @@ -39,8 +44,8 @@ jobs: release: runs-on: ubuntu-latest - needs: check-release-version - if: ${{ startsWith(needs.check-release-version.outputs.release-version, 'v') }} + needs: determine-release-version + if: ${{ startsWith(needs.determine-release-version.outputs.release-version, 'v') }} permissions: contents: write @@ -49,22 +54,44 @@ jobs: environment: release steps: - - uses: actions/checkout@v5 - - uses: actions/setup-node@v4 + - name: Checkout Repository + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 + id: checkout + with: + persist-credentials: true + + - name: Setup Node.js + uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 with: - node-version: '22' + node-version: 'lts/*' registry-url: 'https://registry.npmjs.org' - - run: npm install -g npm@latest - - run: npm install - - name: Create NPM release + + - name: Install globally latest npm + run: npm install -g npm@latest + id: install-globally-latest-npm + + - name: Install dependencies + run: npm install + id: install-dependencies + + - name: Publish undici on NPM run: npm publish --access public - - run: node scripts/generate-undici-types-package-json.js - - run: npm publish + id: npm-publish-undici + + - name: Generate Types Package + run: node scripts/generate-undici-types-package-json.js + id: generate-types-package + + - name: Publish undici-types on NPM + run: npm publish + id: npm-publish-undici-types working-directory: './types' + - name: Create GitHub release - uses: actions/github-script@v7 + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 + id: create-gh-release with: script: | const defaultBranch = "${{ github.event.repository.default_branch }}" - const versionTag = "${{ needs.check-release-version.outputs.release-version }}" + const versionTag = "${{ needs.determine-release-version.outputs.release-version }}" await require('./scripts/release').release({ github, context, defaultBranch, versionTag }) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index d2cb4a8fb9e..00000000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,78 +0,0 @@ -name: Run tests - -on: - workflow_call: - inputs: - node-version: - required: true - type: string - runs-on: - required: true - type: string - -permissions: - contents: read - -jobs: - test: - name: Test with Node.js ${{ inputs.node-version }} on ${{ inputs.runs-on }} - timeout-minutes: 15 - runs-on: ${{ inputs.runs-on }} - steps: - - name: Checkout - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 - with: - persist-credentials: false - submodules: recursive - - - name: Setup Node.js@${{ inputs.node-version }} - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 - with: - node-version: ${{ inputs.node-version }} - - - name: Print version information - run: | - echo OS: $(node -p "os.version()") - echo Node.js: $(node --version) - echo npm: $(npm --version) - echo git: $(git --version) - - - name: Install dependencies - run: npm install - - - name: Print installed dependencies - run: npm ls --all - continue-on-error: true - - - name: Configure hosts file for WPT (Windows) - if: runner.os == 'Windows' - run: | - cd ${{ github.workspace }}\test\web-platform-tests\wpt - python wpt make-hosts-file | Out-File $env:SystemRoot\System32\drivers\etc\hosts -Encoding ascii -Append - shell: powershell - - - name: Configure hosts file for WPT (Unix) - if: runner.os != 'Windows' - run: | - cd ${{ github.workspace }}/test/web-platform-tests/wpt - python3 wpt make-hosts-file | sudo tee -a /etc/hosts - - - name: Run tests with coverage - id: coverage - if: inputs.runs-on == 'ubuntu-latest' && inputs.node-version == 22 - run: npm run coverage:ci - env: - CI: true - NODE_V8_COVERAGE: ./coverage/tmp - - - name: Run tests - if: steps.coverage.outcome == 'skipped' - run: npm run test:javascript - env: - CI: true - - - name: Coverage Report - if: inputs.runs-on == 'ubuntu-latest' && inputs.node-version == 20 - uses: codecov/codecov-action@fdcc8476540edceab3de004e990f80d881c6cc00 # v5.5.0 - with: - token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/update-cache-tests.yml b/.github/workflows/update-cache-tests.yml index e0fb9eed6c0..a1696737919 100644 --- a/.github/workflows/update-cache-tests.yml +++ b/.github/workflows/update-cache-tests.yml @@ -21,6 +21,8 @@ jobs: - name: Checkout Repository uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 + with: + persist-credentials: true - name: Update Cache Tests run: | diff --git a/README.md b/README.md index eb69c0ca8f4..22c43d0a350 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # undici -[![Node CI](https://github.com/nodejs/undici/actions/workflows/nodejs.yml/badge.svg)](https://github.com/nodejs/undici/actions/workflows/nodejs.yml) [![neostandard javascript style](https://img.shields.io/badge/neo-standard-7fffff?style=flat\&labelColor=ff80ff)](https://github.com/neostandard/neostandard) [![npm version](https://badge.fury.io/js/undici.svg)](https://badge.fury.io/js/undici) [![codecov](https://codecov.io/gh/nodejs/undici/branch/main/graph/badge.svg?token=yZL6LtXkOA)](https://codecov.io/gh/nodejs/undici) +[![Node CI](https://github.com/nodejs/undici/actions/workflows/ci.yml/badge.svg)](https://github.com/nodejs/undici/actions/workflows/nodejs.yml) [![neostandard javascript style](https://img.shields.io/badge/neo-standard-7fffff?style=flat\&labelColor=ff80ff)](https://github.com/neostandard/neostandard) [![npm version](https://badge.fury.io/js/undici.svg)](https://badge.fury.io/js/undici) [![codecov](https://codecov.io/gh/nodejs/undici/branch/main/graph/badge.svg?token=yZL6LtXkOA)](https://codecov.io/gh/nodejs/undici) An HTTP/1.1 client, written from scratch for Node.js.