|
| 1 | +name: Test and upload Python package |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + push: |
| 6 | + branches: [master] |
| 7 | + tags: |
| 8 | + - 'v*' |
| 9 | + - '!v*-dev' |
| 10 | + |
| 11 | +env: |
| 12 | + ZEEKROOT: /usr/local/zeek |
| 13 | + |
| 14 | +jobs: |
| 15 | + test: |
| 16 | + strategy: |
| 17 | + fail-fast: false |
| 18 | + matrix: |
| 19 | + # Test Zeek LTS, latest, and nightly, and |
| 20 | + # don't fail for the nightly one. |
| 21 | + include: |
| 22 | + - repo: zeek |
| 23 | + version: latest |
| 24 | + continue_on_error: false |
| 25 | + - repo: zeek |
| 26 | + version: lts |
| 27 | + continue_on_error: false |
| 28 | + - repo: zeek-dev |
| 29 | + version: latest |
| 30 | + continue_on_error: true |
| 31 | + |
| 32 | + runs-on: ubuntu-latest |
| 33 | + continue-on-error: ${{ matrix.continue_on_error }} |
| 34 | + container: |
| 35 | + image: zeek/${{ matrix.repo }}:${{ matrix.version }} |
| 36 | + |
| 37 | + steps: |
| 38 | + - name: Install build environment |
| 39 | + run: | |
| 40 | + apt-get update |
| 41 | + apt-get install -y --no-install-recommends cmake g++ libssl-dev libpcap-dev make |
| 42 | + - name: Remove zkg installation |
| 43 | + # Rule out confusion between test environment and pre-existing zkg: |
| 44 | + run: | |
| 45 | + rm $ZEEKROOT/bin/zkg $ZEEKROOT/share/man/man1/zkg.1 |
| 46 | + rm -r $ZEEKROOT/etc/zkg |
| 47 | + rm -r $ZEEKROOT/lib/zeek/python/zeekpkg |
| 48 | + rm -r $ZEEKROOT/var/lib/zkg |
| 49 | + - uses: actions/checkout@v3 |
| 50 | + - name: Run unit tests |
| 51 | + run: btest -j -A -d -c testing/btest.cfg |
| 52 | + - uses: actions/upload-artifact@v3 |
| 53 | + if: failure() |
| 54 | + with: |
| 55 | + name: btest-${{ matrix.repo }}-${{ matrix.version }} |
| 56 | + path: testing/.tmp/ |
| 57 | + |
| 58 | + upload: |
| 59 | + runs-on: ubuntu-latest |
| 60 | + needs: [test] |
| 61 | + if: github.repository == 'zeek/package-manager' && github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') |
| 62 | + steps: |
| 63 | + - uses: actions/checkout@v3 |
| 64 | + - name: Check release version |
| 65 | + # This fails e.g. if VERSION contains a dev commits suffix, |
| 66 | + # since we don't want to push these to PyPI. Accepts two- |
| 67 | + # and three-component version numbers (e.g. 1.0 and 1.0.1). |
| 68 | + run: | |
| 69 | + grep -E -x '[0-9]+\.[0-9]+(\.[0-9]+)?' VERSION |
| 70 | + - name: Build wheel |
| 71 | + run: | |
| 72 | + make dist |
| 73 | + - name: Upload to PyPI |
| 74 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 75 | + with: |
| 76 | + user: __token__ |
| 77 | + password: ${{ secrets.PYPI_API_TOKEN }} |
0 commit comments