diff --git a/.github/actions/undici-wpt-current/action.yml b/.github/actions/undici-wpt-current/action.yml new file mode 100644 index 00000000000000..ffedcaa0fadc92 --- /dev/null +++ b/.github/actions/undici-wpt-current/action.yml @@ -0,0 +1,56 @@ +name: Run undici WPT (current) +description: Runs undici WPT tests for undici >= 7 and merges results into the Node.js WPT report + +inputs: + undici-version: + required: true + description: undici version tag to checkout + wpt-report: + required: true + description: Path to the Node.js WPT report to merge into + +runs: + using: composite + steps: + - name: Checkout undici + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + repository: nodejs/undici + persist-credentials: false + path: undici + clean: false + ref: ${{ inputs.undici-version }} + - name: Prepare WPT checkout + shell: bash + run: | + rm -rf undici/test/web-platform-tests/wpt + mv test/fixtures/wpt undici/test/web-platform-tests/wpt + - name: Configure hosts + shell: bash + working-directory: undici/test/web-platform-tests/wpt + run: python3 wpt make-hosts-file | sudo tee -a /etc/hosts + - name: Install dependencies + shell: bash + working-directory: undici + run: npm install + - name: Run WPT + shell: bash + working-directory: undici + env: + CI: 'true' + WPT_REPORT: ${{ github.workspace }}/undici/wptreport.json + run: npm run test:wpt || true + - name: Merge report + shell: bash + env: + NODE_WPT_REPORT: ${{ inputs.wpt-report }} + UNDICI_WPT_REPORT: ${{ github.workspace }}/undici/wptreport.json + run: | + if [ -f "$UNDICI_WPT_REPORT" ]; then + jq -sc ' + .[0].results += .[1].results | + .[0].time_end = .[1].time_end | + .[0] + ' "$NODE_WPT_REPORT" "$UNDICI_WPT_REPORT" > "${NODE_WPT_REPORT}.tmp" + mv "${NODE_WPT_REPORT}.tmp" "$NODE_WPT_REPORT" + fi diff --git a/.github/actions/undici-wpt-legacy/action.yml b/.github/actions/undici-wpt-legacy/action.yml new file mode 100644 index 00000000000000..77a8b3fee46992 --- /dev/null +++ b/.github/actions/undici-wpt-legacy/action.yml @@ -0,0 +1,37 @@ +name: Run undici WPT (legacy) +description: Runs undici WPT tests for undici < 7 and appends results to the Node.js WPT report + +inputs: + undici-version: + required: true + description: undici version tag to checkout + wpt-report: + required: true + description: Path to the Node.js WPT report + +runs: + using: composite + steps: + - name: Checkout undici + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + repository: nodejs/undici + persist-credentials: false + path: undici + clean: false + ref: ${{ inputs.undici-version }} + - name: Prepare WPT checkout + shell: bash + run: | + rm -rf undici/test/wpt/tests + mv test/fixtures/wpt undici/test/wpt/tests + - name: Install dependencies + shell: bash + working-directory: undici + run: npm install + - name: Run WPT + shell: bash + working-directory: undici + env: + WPT_REPORT: ${{ inputs.wpt-report }} + run: npm run test:wpt || true diff --git a/.github/workflows/daily-wpt-fyi.yml b/.github/workflows/daily-wpt-fyi.yml index 5ec2662d21df61..3899b6bd28e1a5 100644 --- a/.github/workflows/daily-wpt-fyi.yml +++ b/.github/workflows/daily-wpt-fyi.yml @@ -96,6 +96,48 @@ jobs: echo "WPT_REPORT=$(pwd)/out/wpt/wptreport.json" >> $GITHUB_ENV fi + # undici WPT Runner + - name: Set env.UNDICI_VERSION + if: ${{ env.WPT_REPORT != '' }} + run: | + UNDICI_VERSION=$(jq -r '.version' < deps/undici/src/package.json) + echo "UNDICI_VERSION=v$UNDICI_VERSION" >> $GITHUB_ENV + if [ "${UNDICI_VERSION%%.*}" -ge 7 ]; then + echo "UNDICI_WPT=current" >> $GITHUB_ENV + else + echo "UNDICI_WPT=legacy" >> $GITHUB_ENV + fi + # Checkout composite actions from the default branch since the + # version-specific checkout above overwrites .github/actions/ + - name: Checkout undici WPT actions + if: ${{ env.WPT_REPORT != '' }} + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + sparse-checkout: | + .github/actions/undici-wpt-current + .github/actions/undici-wpt-legacy + sparse-checkout-cone-mode: false + persist-credentials: false + path: _wpt_actions + clean: false + - name: Place undici WPT actions + if: ${{ env.WPT_REPORT != '' }} + run: | + mkdir -p .github/actions + cp -r _wpt_actions/.github/actions/undici-wpt-* .github/actions/ + - name: Run undici WPT (current) + if: ${{ env.UNDICI_WPT == 'current' }} + uses: ./.github/actions/undici-wpt-current + with: + undici-version: ${{ env.UNDICI_VERSION }} + wpt-report: ${{ env.WPT_REPORT }} + - name: Run undici WPT (legacy) + if: ${{ env.UNDICI_WPT == 'legacy' }} + uses: ./.github/actions/undici-wpt-legacy + with: + undici-version: ${{ env.UNDICI_VERSION }} + wpt-report: ${{ env.WPT_REPORT }} + # Upload artifacts - name: Clone report for upload if: ${{ env.WPT_REPORT != '' }}