name: CI

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2
    - name: Use Node.js 18.x
      uses: actions/setup-node@v1
      with:
        node-version: 18.x
    - run: npm install
    - run: npm test
    
  test:
    runs-on: ubuntu-latest
    timeout-minutes: 5
    if: github.ref == 'refs/heads/master' #for prs, we use the pr-workflow
    strategy:
      matrix:
        mcVersionIndex: ['1.8.8', '1.9.4', '1.10.2', '1.11.2', '1.12.2', '1.13.2', '1.14.4', '1.15.2', '1.16.5', '1.17.1', '1.18.2', '1.19', '1.19.2', '1.19.3', '1.19.4', '1.20.1']
      fail-fast: false

    steps:
    - uses: actions/checkout@v2
    - uses: actions/setup-node@v1
      with:
        node-version: 18.x
    - name: Setup Java JDK
      uses: actions/setup-java@v1.4.3
      with:
        java-version: 17
        java-package: jre
    - run: npm install
    - name: Use Dumper
      run: |
        mkdir output
        node bin/dumpPackets -v ${{ matrix.mcVersionIndex }} -o output/${{ matrix.mcVersionIndex }}
    - name: Upload artifacts
      uses: actions/upload-artifact@v2
      with:
        name: packets
        path: output
    
