diff --git a/.github/workflows/code_quality.yml b/.github/workflows/code_quality.yml index 697d541f7..ee26452c2 100644 --- a/.github/workflows/code_quality.yml +++ b/.github/workflows/code_quality.yml @@ -8,15 +8,19 @@ on: pull_request: jobs: + node-versions: + uses: ./.github/workflows/get-supported-node-versions.yml + check-code-quality: name: Check code quality runs-on: ubuntu-latest + needs: node-versions steps: - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: 12 + node-version: ${{ needs.node-versions.outputs.default-version }} - name: Checkout code uses: actions/checkout@v4 - name: Install dependencies diff --git a/.github/workflows/code_sample_checker.yml b/.github/workflows/code_sample_checker.yml index c58f7226e..0fe7b3d14 100644 --- a/.github/workflows/code_sample_checker.yml +++ b/.github/workflows/code_sample_checker.yml @@ -2,9 +2,13 @@ name: Code sample checker on: pull_request jobs: + node-versions: + uses: ./.github/workflows/get-supported-node-versions.yml + test-code-samples: name: Check code samples runs-on: ${{matrix.os}} + needs: node-versions strategy: matrix: @@ -23,7 +27,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: 10 + node-version: ${{ needs.node-versions.outputs.default-version }} - name: Install dependencies and compile client run: | npm install diff --git a/.github/workflows/coverage_runner.yml b/.github/workflows/coverage_runner.yml index 1a26cb535..49cf9a38c 100644 --- a/.github/workflows/coverage_runner.yml +++ b/.github/workflows/coverage_runner.yml @@ -28,9 +28,14 @@ jobs: member-name: ${{ github.actor }} token: ${{ secrets.PAT }} + node-versions: + uses: ./.github/workflows/get-supported-node-versions.yml + run-tests: name: Run Tests on (${{ matrix.os }}) - needs: [check_for_membership] + needs: + - check_for_membership + - node-versions if: github.event_name == 'push' || needs.check_for_membership.outputs.check-result == 'true' || github.event_name == 'workflow_dispatch' runs-on: ${{ matrix.os }} strategy: @@ -64,7 +69,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: 10 + node-version: ${{ needs.node-versions.outputs.default-version }} - name: Checkout to test artifacts uses: actions/checkout@v4 diff --git a/.github/workflows/get-supported-node-versions.yml b/.github/workflows/get-supported-node-versions.yml new file mode 100644 index 000000000..b6fd2c031 --- /dev/null +++ b/.github/workflows/get-supported-node-versions.yml @@ -0,0 +1,35 @@ +name: Get supported Node.js versions + +on: + workflow_call: + outputs: + node-versions: + value: ${{ jobs.get-supported-node-versions.outputs.node-versions }} + default-version: + value: ${{ jobs.get-supported-node-versions.outputs.default-version }} + +jobs: + get-supported-node-versions: + runs-on: ubuntu-latest + outputs: + node-versions: ${{ steps.get_versions.outputs.node-versions }} + default-version: ${{ steps.get_versions.outputs.default-version }} + steps: + - name: Get supported Node.js versions + id: get_versions + run: | + # Look for versions that are: + # - Currently supported + # - That are LTS + # - Within LTS date range (i.e. not future LTS) + NODE_VERSIONS=$(curl --silent https://raw.githubusercontent.com/nodejs/Release/main/schedule.json | jq --compact-output ' + def today: now | strftime("%Y-%m-%d"); + to_entries + | map(select(.value.end > today and .value.lts != null and .value.lts < today)) + | [.[0].key, .[-1].key] + | unique + ') + + echo "node-versions=${NODE_VERSIONS}" >> ${GITHUB_OUTPUT} + # Default to using the newest version + echo "default-version=$(jq -r '.[1]' <<< ${NODE_VERSIONS})" >> ${GITHUB_OUTPUT} diff --git a/.github/workflows/nightly_runner_maintenance.yml b/.github/workflows/nightly_runner_maintenance.yml index 74d3b1382..addf662b7 100644 --- a/.github/workflows/nightly_runner_maintenance.yml +++ b/.github/workflows/nightly_runner_maintenance.yml @@ -4,14 +4,18 @@ on: schedule: - cron: '0 2 */2 * *' jobs: + node-versions: + uses: ./.github/workflows/get-supported-node-versions.yml + run-tests: runs-on: ${{ matrix.os }} + needs: node-versions name: Run tests of branch ${{ matrix.branch }} on ${{ matrix.os }} with Node ${{ matrix.nodejs_version }} strategy: matrix: branch: [ 5.0.x, 4.2.x, 4.1.x, 4.0.x ] os: [ ubuntu-latest, windows-latest ] - nodejs_version: [ 10, 18 ] + nodejs_version: ${{ fromJSON(needs.node-versions.outputs.node-versions) }} fail-fast: false steps: - name: Setup Java diff --git a/.github/workflows/nightly_runner_master.yml b/.github/workflows/nightly_runner_master.yml index ee8b17d36..0481973b2 100644 --- a/.github/workflows/nightly_runner_master.yml +++ b/.github/workflows/nightly_runner_master.yml @@ -4,13 +4,17 @@ on: schedule: - cron: '0 2 * * *' jobs: + node-versions: + uses: ./.github/workflows/get-supported-node-versions.yml + run-tests: runs-on: ${{ matrix.os }} + needs: node-versions name: Run tests of master on ${{ matrix.os }} with Node ${{ matrix.nodejs_version }} strategy: matrix: os: [ ubuntu-latest, windows-latest ] - nodejs_version: [ 10, 18 ] + nodejs_version: ${{ fromJSON(needs.node-versions.outputs.node-versions) }} fail-fast: false steps: - name: Checkout code