update github actions #30
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: test | |
env: | |
POETRY_VERSION: "1.3.1" | |
on: | |
push: | |
pull_request: | |
branches: | |
- "**" | |
workflow_dispatch: | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
test: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-20.04, windows-latest] # [ubuntu-20.04, macos-latest, windows-latest] | |
python: ["3.11.3"] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python ${{ matrix.python }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python }} | |
cache: pip | |
- name: Install libraries for ubuntu | |
if: matrix.os == 'ubuntu-20.04' | |
run: sudo apt-get install libsndfile1 | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip setuptools wheel | |
python -m pip install -r requirements-test.txt | |
- name: Add Path for ubuntu | |
if: matrix.os == 'ubuntu-20.04' | |
run: | |
echo "$HOME/.local/bin" >> $GITHUB_PATH | |
- name: Add Path for Windows | |
if: matrix.os == 'windows-latest' | |
run: | |
echo "C:\Users\runneradmin\AppData\Roaming\Python\Scripts" >> $GITHUB_PATH | |
- name: Run poetry | |
run: | | |
poetry export --without-hashes -o requirements.txt.check | |
poetry export --without-hashes --with dev -o requirements-dev.txt.check | |
poetry export --without-hashes --with test -o requirements-test.txt.check | |
poetry export --without-hashes --with license -o requirements-license.txt.check | |
- name: Check poetry export ubuntu | |
continue-on-error: true | |
id: poetry_export_check_ubuntu | |
if: matrix.os == 'ubuntu-20.04' | |
run: | |
diff -q requirements.txt requirements.txt.check || \ | |
diff -q requirements-dev.txt requirements-dev.txt.check || \ | |
diff -q requirements-test.txt requirements-test.txt.check || \ | |
diff -q requirements-license.txt requirements-license.txt.check > /dev/null | |
if [$? = 1]; then | |
exit 1 | |
fi | |
- name: Check poetry export windows | |
continue-on-error: true | |
id: poetry_export_check_windows | |
if: matrix.os == 'windows-latest' | |
run: | |
diff /M requirements.txt requirements.txt.check && \ | |
diff /M requirements-dev.txt requirements-dev.txt.check && \ | |
diff /M requirements-test.txt requirements-test.txt.check && \ | |
diff /M requirements-license.txt requirements-license.txt.check | |
if %ERRORLEVEL% == 1 exit 1 | |
- name: Check poetry export Error handling | |
if: ${{ steps.poetry_export_check.outcome_ubuntu == 'failure' }} | |
run: | |
echo "poetry export has some diff on ubuntu" | |
exit 1 | |
- name: Check poetry export Error handling | |
if: ${{ steps.poetry_export_check.outcome_windows == 'failure' }} | |
run: | |
echo "poetry export has some diff on windows" | |
exit 1 | |
- run: pysen run lint | |
- name: Run pytest and get coverage | |
run: | | |
coverage run --omit=test/* -m pytest | |
- name: Submit coverage to Coveralls | |
if: matrix.os == 'ubuntu-20.04' | |
run: coveralls --service=github | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create coverage result | |
if: github.event_name == 'pull_request' && matrix.os == 'ubuntu-20.04' | |
run: | | |
mkdir report | |
coverage report > report/report.txt | |
echo ${{ github.event.number }} > report/pr_num.txt | |
- name: Upload coverage result | |
if: github.event_name == 'pull_request' && matrix.os == 'ubuntu-20.04' | |
uses: actions/upload-artifact@v3 | |
with: | |
name: report | |
path: report/ | |
- name: Check licenses | |
shell: bash | |
run: | | |
OUTPUT_LICENSE_JSON_PATH=/dev/null \ | |
bash build_util/create_venv_and_generate_licenses.bash |