Skip to content

Commit

Permalink
Improve per version CI following mineflayer example. (#646)
Browse files Browse the repository at this point in the history
* Improve per version CI following mineflayer example.

* Change build name for test.

* fix simple test
  • Loading branch information
rom1504 authored Jan 4, 2024
1 parent 05de798 commit 98fc454
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 67 deletions.
57 changes: 41 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,54 @@ name: CI

on:
push:
branches: [ master ]
branches:
- master
pull_request:
branches: [ master, "1.13" ]

jobs:
build:
Lint:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Use Node.js 18.x
uses: actions/[email protected]
with:
node-version: 18.x
- run: npm i && npm run lint

PrepareSupportedVersions:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}

steps:
- uses: actions/checkout@v2
- name: Use Node.js 18.x
uses: actions/[email protected]
with:
node-version: 18.x
- id: set-matrix
run: |
node -e "
const supportedVersions = require('./src/lib/version').supportedVersions;
console.log('matrix='+JSON.stringify({'include': supportedVersions.map(mcVersion => ({mcVersion}))}))
" >> $GITHUB_OUTPUT
Test:
needs: PrepareSupportedVersions
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
mcVersionIndex: [0, 1, 2, 3, 4, 5, 6, 7, 8]
matrix: ${{fromJson(needs.PrepareSupportedVersions.outputs.matrix)}}
fail-fast: false

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm install
- env:
CIRCLE_NODE_INDEX: ${{ matrix.mcVersionIndex }}
CIRCLE_NODE_TOTAL: 9
run: npm test
- uses: actions/checkout@v2
- name: Use Node.js 18.x
uses: actions/[email protected]
with:
node-version: 18.x
- name: Install Dependencies
run: npm install
- name: Start Tests
run: npm run mocha_test -- -g ${{ matrix.mcVersion }}v
33 changes: 0 additions & 33 deletions test/common/parallel.js

This file was deleted.

8 changes: 1 addition & 7 deletions test/mineflayer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,13 @@ function assertPosEqual (actual, expected, precision = 1) {

const once = require('event-promise')

const { firstVersion, lastVersion } = require('./common/parallel')

squid.supportedVersions.forEach((supportedVersion, i) => {
if (!(i >= firstVersion && i <= lastVersion)) {
return
}

const mcData = require('minecraft-data')(supportedVersion)
const version = mcData.version

const Item = require('prismarine-item')(supportedVersion)

describe('server with mineflayer connection ' + version.minecraftVersion, () => {
describe('server with mineflayer connection ' + supportedVersion + 'v', () => {
/** @type {import('mineflayer').Bot} */
let bot
/** @type {import('mineflayer').Bot} */
Expand Down
5 changes: 1 addition & 4 deletions test/portal.test.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
/* eslint-env mocha */

const squid = require('flying-squid')
const { firstVersion, lastVersion } = require('./common/parallel')
const expect = require('expect').default

squid.supportedVersions.forEach((supportedVersion, i) => {
if (!(i >= firstVersion && i <= lastVersion)) return

const mcData = require('minecraft-data')(supportedVersion)
const version = mcData.version

Expand All @@ -22,7 +19,7 @@ squid.supportedVersions.forEach((supportedVersion, i) => {

const { Vec3 } = require('vec3')

describe('generate portal ' + version.minecraftVersion, () => {
describe('generate portal ' + supportedVersion + 'v', () => {
it('generate a line', () => {
expect(generateLine(new Vec3(3, 1, 1), new Vec3(1, 0, 0), 2)).toEqual([new Vec3(3, 1, 1), new Vec3(4, 1, 1)])
})
Expand Down
8 changes: 1 addition & 7 deletions test/simple.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,11 @@ const squid = require('flying-squid')

const settings = require('../config/default-settings')

const { firstVersion, lastVersion } = require('./common/parallel')

squid.supportedVersions.forEach((supportedVersion, i) => {
if (!(i >= firstVersion && i <= lastVersion)) {
return
}

const mcData = require('minecraft-data')(supportedVersion)
const version = mcData.version

describe(`simple server ${version.minecraftVersion}`, () => {
describe(`simple server ${supportedVersion}v`, () => {
let serv

before(done => {
Expand Down

0 comments on commit 98fc454

Please sign in to comment.