Skip to content

PNE-6228: Replace Travis CI with Github Actions #3

PNE-6228: Replace Travis CI with Github Actions

PNE-6228: Replace Travis CI with Github Actions #3

Workflow file for this run

name: CI/CD
on:
push:
branches: [main]
tags: ['*']
pull_request:
branches: [main]
env:
SCALA_VERSION: 2.13.8
JAVA_VERSION: 11
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
test-type: ['scala', 'python']
steps:
- uses: actions/checkout@v2
- name: Set up JDK
if: matrix.test-type == 'scala'
uses: actions/setup-java@v2
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: 'adopt'
- name: Cache SBT dependencies
if: matrix.test-type == 'scala'
uses: actions/cache@v2
with:
path: |
~/.ivy2/cache
~/.sbt
~/.m2
key: ${{ runner.os }}-sbt-${{ hashFiles('**/build.sbt') }}
- name: Run Scala tests
if: matrix.test-type == 'scala'
run: |
sbt -Dsbt.log.noformat=true scalafmtCheckAll
sbt -Dsbt.log.noformat=true +test
- name: Set up Python
if: matrix.test-type == 'python'
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Cache pip dependencies
if: matrix.test-type == 'python'
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
- name: Install Python dependencies
if: matrix.test-type == 'python'
run: |
cd python
make
pip install --only-binary=numpy,scipy -r requirements.txt
pip install -r test_requirements.txt
- name: Run Python tests
if: matrix.test-type == 'python'
run: |
cd python
nosetests
release:
needs: test
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/'))
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK
uses: actions/setup-java@v2
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: 'adopt'
- name: Release to Maven Central
env:
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
PGP_SECRET: ${{ secrets.PGP_SECRET }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
run: sbt ci-release
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install dependencies for PyPI release
run: |
sudo apt-get install -y pandoc
cd python
make
pip install --only-binary=numpy,scipy -r requirements.txt
- name: Build and publish to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
cd python
python setup.py sdist bdist_wheel
pip install twine
twine upload dist/*
if: startsWith(github.ref, 'refs/tags/')