Merge pull request #204 from ADSSU/main #121
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: Check Code | |
on: | |
pull_request: | |
push: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: [3.7, 3.8, 3.9] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v3 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -e .[dev] | |
sudo apt install gringo | |
sudo apt-get install graphviz | |
- if: ${{ matrix.python-version == '3.9' }} | |
name: Get branch name | |
run: | | |
REF=${{ github.ref }} | |
echo "github.ref: $REF" | |
IFS='/' read -ra PATHS <<< "$REF" | |
BRANCH_NAME="${PATHS[1]}_${PATHS[2]}" | |
echo $BRANCH_NAME | |
echo "BRANCH=$(echo ${BRANCH_NAME})" >> $GITHUB_ENV | |
- if: ${{ matrix.python-version == '3.9' }} | |
name: Create placeholder coverage badge | |
uses: schneegans/[email protected] | |
with: | |
auth: ${{ secrets.GIST_SECRET }} | |
gistID: 03ac305b42d7c9ad4ef3213341bf3f2f | |
filename: macq__${{ env.BRANCH }}.json | |
label: Coverage | |
message: n/a | |
color: red | |
namedLogo: pytest | |
- name: Linting | |
run: | | |
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics | |
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics | |
- name: Tests | |
run: pytest | |
# Only get coverage once | |
- if: ${{ matrix.python-version == '3.9' }} | |
name: Get coverage | |
run: | | |
REPORT="$(pytest --cov=macq)" | |
for line in "${REPORT[@]}"; do echo "$line"; done | |
echo "COVERAGE=$(echo $REPORT | tail -c85 | head -c3)" >> $GITHUB_ENV | |
- if: ${{ matrix.python-version == '3.9' }} | |
name: Create coverage badge | |
uses: schneegans/[email protected] | |
with: | |
auth: ${{ secrets.GIST_SECRET }} | |
gistID: 03ac305b42d7c9ad4ef3213341bf3f2f | |
filename: macq__${{ env.BRANCH }}.json | |
label: Coverage | |
message: ${{ env.COVERAGE }} | |
color: green | |
namedLogo: pytest |