From 8f66c4dac76527d3ab14dd5def4409b1877d56ac Mon Sep 17 00:00:00 2001 From: Lokendra Singh Date: Wed, 10 Mar 2021 00:55:12 +0530 Subject: [PATCH 1/6] add: github workflow --- .github/workflows/build.yaml | 39 ++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/workflows/build.yaml diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..15f5145 --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,39 @@ +name: apertium-python CI Build + +on: [push] + +jobs: + build: + + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.6, 3.7, 3.8] + + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install pipenv + python3 setup.py install + pipenv install --dev --system + - name: Flake8 checks + run: | + flake8 --verbose apertium + - name: mypy checks + run: | + mypy apertium --strict --any-exprs-report .mypy_coverage --ignore-missing-imports + cat .mypy_coverage/any-exprs.txt + coverage=$(tail -1 .mypy_coverage/any-exprs.txt | grep -Eo '[0-9\.]+%' | sed 's/%$//') + if (( $(echo "$coverage < 95" | bc -l) )); then + exit 1 + fi + - name: code coverage and unittest + run: | + coverage run -m unittest --verbose --buffer tests + coverage report --show-missing --fail-under 90 --include 'apertium/*' From 32aabae3ab35e578d8bacb924c784fbedcdd38c1 Mon Sep 17 00:00:00 2001 From: Lokendra Singh Date: Thu, 18 Mar 2021 12:26:19 +0530 Subject: [PATCH 2/6] actions: pipenv cache --- .github/workflows/build.yaml | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 15f5145..41cca86 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -16,12 +16,22 @@ jobs: uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} - - name: Install dependencies + - name: Install pipenv run: | python -m pip install --upgrade pip - pip install pipenv + pip install --upgrade pipenv + - id: cache-pipenv + uses: actions/cache@v1 + with: + path: ~/.local/share/virtualenvs + key: ${{ runner.os }}-pipenv-${{ hashFiles('**/Pipfile.lock') }} + - name: Install dependencies + if: steps.cache-pipenv.outputs.cache-hit != 'true' + run: | + pipenv install --dev + - name: Install apertium-python + run: | python3 setup.py install - pipenv install --dev --system - name: Flake8 checks run: | flake8 --verbose apertium From c4b9db8af9859676f7d2e3f0856db88eef6ba66b Mon Sep 17 00:00:00 2001 From: Lokendra Singh Date: Thu, 18 Mar 2021 12:28:53 +0530 Subject: [PATCH 3/6] actions: trigger on PR --- .github/workflows/build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 41cca86..606700b 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -1,6 +1,6 @@ name: apertium-python CI Build -on: [push] +on: [push, pull_request] jobs: build: From a885079345c38a184485fdc5475ed2e01efaed73 Mon Sep 17 00:00:00 2001 From: Lokendra Singh Date: Thu, 18 Mar 2021 12:45:02 +0530 Subject: [PATCH 4/6] actions: pipenv run --- .github/workflows/build.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 606700b..3233ed8 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -34,10 +34,10 @@ jobs: python3 setup.py install - name: Flake8 checks run: | - flake8 --verbose apertium + pipenv run flake8 --verbose apertium - name: mypy checks run: | - mypy apertium --strict --any-exprs-report .mypy_coverage --ignore-missing-imports + pipenv run mypy apertium --strict --any-exprs-report .mypy_coverage --ignore-missing-imports cat .mypy_coverage/any-exprs.txt coverage=$(tail -1 .mypy_coverage/any-exprs.txt | grep -Eo '[0-9\.]+%' | sed 's/%$//') if (( $(echo "$coverage < 95" | bc -l) )); then @@ -45,5 +45,5 @@ jobs: fi - name: code coverage and unittest run: | - coverage run -m unittest --verbose --buffer tests - coverage report --show-missing --fail-under 90 --include 'apertium/*' + pipenv run coverage run -m unittest --verbose --buffer tests + pipenv run coverage report --show-missing --fail-under 90 --include 'apertium/*' From 7e48f8dd1dc0a311a9ae529c1c6c6666b1828ccc Mon Sep 17 00:00:00 2001 From: Lokendra Singh Date: Thu, 18 Mar 2021 12:50:20 +0530 Subject: [PATCH 5/6] actions: cache@v2 --- .github/workflows/build.yaml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 3233ed8..86fe7e5 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -20,11 +20,12 @@ jobs: run: | python -m pip install --upgrade pip pip install --upgrade pipenv - - id: cache-pipenv - uses: actions/cache@v1 + - uses: actions/cache@v2 with: path: ~/.local/share/virtualenvs - key: ${{ runner.os }}-pipenv-${{ hashFiles('**/Pipfile.lock') }} + key: ${{ runner.os }}-pipenv-${{ hashFiles('Pipfile.lock') }} + restore-keys: | + ${{ runner.os }}-pipenv- - name: Install dependencies if: steps.cache-pipenv.outputs.cache-hit != 'true' run: | From abdd66f60690dac7bbbd90a599fbe59b21615d84 Mon Sep 17 00:00:00 2001 From: Lokendra Singh Date: Thu, 18 Mar 2021 13:10:26 +0530 Subject: [PATCH 6/6] actions: runs-on windows --- .github/workflows/build.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 86fe7e5..2eea461 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -4,10 +4,10 @@ on: [push, pull_request] jobs: build: - - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} strategy: matrix: + os: [ubuntu-latest, windows-latest] python-version: [3.6, 3.7, 3.8] steps: