|
| 1 | +name: Test |
| 2 | +on: |
| 3 | + push: |
| 4 | + pull_request: |
| 5 | +jobs: |
| 6 | + is_release: |
| 7 | + runs-on: ubuntu-latest |
| 8 | + outputs: |
| 9 | + type: ${{ steps.get_type.outputs.type }} |
| 10 | + continue-on-error: true |
| 11 | + steps: |
| 12 | + - uses: actions/checkout@v4 |
| 13 | + with: |
| 14 | + fetch-depth: 0 |
| 15 | + - id: get_type |
| 16 | + run: echo $( git tag --points-at HEAD | grep -q -e '^.*@.*$' && echo 'type=::release::' || echo "type=::norelease::" ) >> "$GITHUB_OUTPUT" |
| 17 | + test: |
| 18 | + runs-on: ubuntu-latest |
| 19 | + strategy: |
| 20 | + matrix: |
| 21 | + node-version: [16.x, 18.x, 20.x, 22.x] |
| 22 | + steps: |
| 23 | + - uses: actions/checkout@v4 |
| 24 | + with: |
| 25 | + fetch-depth: 0 |
| 26 | + - name: Use Node.js ${{ matrix.node-version }} |
| 27 | + uses: actions/setup-node@v4 |
| 28 | + with: |
| 29 | + node-version: ${{ matrix.node-version }} |
| 30 | + - run: npm install |
| 31 | + - run: npm run test |
| 32 | + test_legacy: |
| 33 | + needs: [is_release] |
| 34 | + if: ${{ needs.is_release.outputs.type == '::norelease::' }} |
| 35 | + runs-on: ubuntu-latest |
| 36 | + strategy: |
| 37 | + matrix: |
| 38 | + node-version: [14.x] |
| 39 | + steps: |
| 40 | + - uses: actions/checkout@v4 |
| 41 | + with: |
| 42 | + fetch-depth: 0 |
| 43 | + - name: Use Node.js ${{ matrix.node-version }} |
| 44 | + uses: actions/setup-node@v4 |
| 45 | + with: |
| 46 | + node-version: ${{ matrix.node-version }} |
| 47 | + - run: | |
| 48 | + cwd=`pwd` |
| 49 | + for pkg in packages/*/package.json; do |
| 50 | + cd $cwd/`dirname $pkg` |
| 51 | + npm install |
| 52 | + npm run test:legacy; |
| 53 | + done |
| 54 | + # - run: | |
| 55 | + # echo 'Test csv generate' |
| 56 | + # cwd=`pwd` |
| 57 | + # cd $cwd/packages/csv-generate |
| 58 | + # npm install |
| 59 | + # npm run test:legacy |
| 60 | + # npm link |
| 61 | + # cd $pwd |
| 62 | + # - run: | |
| 63 | + # echo 'Test stream transform' |
| 64 | + # cwd=`pwd` |
| 65 | + # cd $cwd/packages/stream-transform |
| 66 | + # npm install |
| 67 | + # npm link csv-generate |
| 68 | + # npm run test:legacy |
| 69 | + # npm link |
| 70 | + # cd $pwd |
| 71 | + # - run: | |
| 72 | + # echo 'Test csv parse' |
| 73 | + # cwd=`pwd` |
| 74 | + # cd $cwd/packages/csv-parse |
| 75 | + # npm install |
| 76 | + # npm link csv-generate |
| 77 | + # npm link stream-transform |
| 78 | + # npm run test:legacy |
| 79 | + # npm link |
| 80 | + # cd $pwd |
| 81 | + # - run: | |
| 82 | + # echo 'Test csv stringify' |
| 83 | + # cwd=`pwd` |
| 84 | + # cd $cwd/packages/csv-stringify |
| 85 | + # npm install |
| 86 | + # npm link csv-generate |
| 87 | + # npm run test:legacy |
| 88 | + # npm link |
| 89 | + # cd $pwd |
| 90 | + # - run: | |
| 91 | + # echo 'Test csv' |
| 92 | + # cwd=`pwd` |
| 93 | + # cd $cwd/packages/csv |
| 94 | + # npm install |
| 95 | + # npm link csv-generate |
| 96 | + # npm link csv-parse |
| 97 | + # npm link csv-stringify |
| 98 | + # npm link stream-transform |
| 99 | + # npm run test:legacy |
| 100 | + # npm link |
| 101 | + # cd $pwd |
| 102 | + publish: |
| 103 | + needs: [is_release, test] |
| 104 | + if: ${{ needs.is_release.outputs.type == '::release::' }} |
| 105 | + runs-on: ubuntu-latest |
| 106 | + steps: |
| 107 | + - uses: actions/checkout@v4 |
| 108 | + with: |
| 109 | + fetch-depth: 0 |
| 110 | + - uses: actions/setup-node@v4 |
| 111 | + with: |
| 112 | + node-version: "22.x" |
| 113 | + registry-url: "https://registry.npmjs.org" |
| 114 | + - run: npm ci |
| 115 | + - run: npm run publish |
| 116 | + env: |
| 117 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
0 commit comments