# This workflow will do a clean install of node dependencies, cache/restore them, build the source code and run tests across different versions of node # For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions name: Node.js CI on: push: pull_request: # Superseded runs of a branch or pull request are cancelled. Runs on master # each get their own group so every commit there is tested. concurrency: group: ${{ github.workflow }}-${{ github.ref == 'refs/heads/master' && github.sha || github.ref }} cancel-in-progress: true env: NODE_VERSION: 24.x jobs: changes: uses: ./.github/workflows/ci-changes.yml test: needs: changes if: ${{ !cancelled() && needs.changes.outputs.build_and_test != 'false' }} runs-on: ubuntu-latest timeout-minutes: 15 strategy: fail-fast: false matrix: # To stay within the concurrent job limit, every Factorio version is # tested on the latest Node.js, and every other supported Node.js # version only with the latest Factorio. Coverage is performed on the # oldest supported Node.js. # Node.js release schedule: https://nodejs.org/en/about/releases/ # Supported factorio versions are latest stable and one minor version before stable (even if from a previous major) node-version: [26.x] factorio-version: [1.1.110, 2.0.77, 2.1.17] # The tests run in two halves of similar length on separate runners, # the clusterioctl, plugin system and instance integration tests and the rest. tests: [ctl, other] include: - node-version: 24.x factorio-version: 2.1.17 tests: ctl - node-version: 24.x factorio-version: 2.1.17 tests: other - node-version: 22.x factorio-version: 2.1.17 tests: ctl coverage: true - node-version: 22.x factorio-version: 2.1.17 tests: other coverage: true steps: - uses: actions/checkout@v7 - name: Prepare and install uses: ./.github/actions/pnpm-install with: node-version: ${{ matrix.node-version }} - name: Use Factorio ${{ matrix.factorio-version }} run: wget -q -O factorio.tar.gz https://www.factorio.com/get-download/${{ matrix.factorio-version }}/headless/linux64 && tar -xf factorio.tar.gz && rm factorio.tar.gz - name: Run tests if: ${{ !matrix.coverage }} run: pnpm test --grep "^(Integration of Clusterio (clusterioctl|plugin system)|Clusterio Instance) " ${{ matrix.tests == 'other' && '--invert' || '' }} - name: Run coverage if: ${{ matrix.coverage }} run: pnpm run ci-cover --grep "^(Integration of Clusterio (clusterioctl|plugin system)|Clusterio Instance) " ${{ matrix.tests == 'other' && '--invert' || '' }} - name: Upload coverage to Codecov if: ${{ matrix.coverage }} uses: codecov/codecov-action@v7 with: files: ./coverage/lcov.info # Otherwise the raw V8 coverage in coverage/tmp is uploaded as well disable_search: true token: ${{ secrets.CODECOV_TOKEN }} - name: Upload test logs for debugging if: ${{ !cancelled() }} uses: actions/upload-artifact@v7 with: name: logs-${{ matrix.node-version }}-${{ matrix.factorio-version }}-${{ matrix.tests }} path: temp/test/logs version-compat: needs: changes if: ${{ !cancelled() && needs.changes.outputs.build_and_test != 'false' }} runs-on: ubuntu-latest timeout-minutes: 15 env: # npm version spec for the published side of the compatibility test. # If each release is compatible with the one before it then testing # against the latest release transitively covers older versions too. PUBLISHED_VERSION: latest strategy: fail-fast: false matrix: include: - controller: local host: published - controller: published host: local steps: - uses: actions/checkout@v7 - name: Prepare and install uses: ./.github/actions/pnpm-install with: node-version: ${{ env.NODE_VERSION }} - name: Test ${{ matrix.controller }} controller with ${{ matrix.host }} host run: > node scripts/version-compat-test.js --controller ${{ matrix.controller }} --host ${{ matrix.host }} --published-version "$PUBLISHED_VERSION" lint: needs: changes if: ${{ !cancelled() && needs.changes.outputs.js_lint != 'false' }} runs-on: ubuntu-latest timeout-minutes: 5 steps: - uses: actions/checkout@v7 - uses: ./.github/actions/pnpm-install with: node-version: ${{ env.NODE_VERSION }} ignore-scripts: true - run: pnpm run lint build: needs: changes if: ${{ !cancelled() && needs.changes.outputs.build_and_test != 'false' }} runs-on: ubuntu-latest timeout-minutes: 5 steps: - uses: actions/checkout@v7 - uses: ./.github/actions/pnpm-install with: node-version: ${{ env.NODE_VERSION }} ignore-scripts: true - run: pnpm run build-mod # Upload build to artifacts - name: Upload build to artifacts uses: actions/upload-artifact@v7 with: name: clusterio_lib path: ./dist if-no-files-found: error