From e034c4047044fb1608b18502aff1c16ce48d0d19 Mon Sep 17 00:00:00 2001 From: zyd Date: Thu, 19 May 2022 05:39:32 +0900 Subject: [PATCH 1/4] pre-commit added in workflows --- .github/workflows/pr-check.yml | 38 ++++++++++++ .../workflows/test-and-upload-to-testapi.yml | 58 ------------------- 2 files changed, 38 insertions(+), 58 deletions(-) create mode 100644 .github/workflows/pr-check.yml delete mode 100644 .github/workflows/test-and-upload-to-testapi.yml diff --git a/.github/workflows/pr-check.yml b/.github/workflows/pr-check.yml new file mode 100644 index 0000000..9e77807 --- /dev/null +++ b/.github/workflows/pr-check.yml @@ -0,0 +1,38 @@ +# This is a basic workflow to help you get started with Actions + +name: Test and pre-commit check + +# Controls when the workflow will run +on: + # Triggers the workflow on push or pull request events but only for the main branch + push: + branches: [ main ] + pull_request: + branches: [ main ] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # This workflow contains a single job called "build" + build: + # The type of runner that the job will run on + runs-on: ubuntu-latest + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v2 + + # Sets up python3 + - uses: actions/setup-python@v2 + with: + python-version: 3.x + + - uses: pre-commit/action@v2.0.3 + + # Tests with unittest + - name: Test with unittest + run: | + python3 -m unittest diff --git a/.github/workflows/test-and-upload-to-testapi.yml b/.github/workflows/test-and-upload-to-testapi.yml deleted file mode 100644 index 7974681..0000000 --- a/.github/workflows/test-and-upload-to-testapi.yml +++ /dev/null @@ -1,58 +0,0 @@ -# This is a basic workflow to help you get started with Actions - -name: Test and Upload to TestApi - -# Controls when the workflow will run -on: - # Triggers the workflow on push or pull request events but only for the main branch - push: - branches: [ main, release* ] - pull_request: - branches: [ main, release* ] - - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: - -# A workflow run is made up of one or more jobs that can run sequentially or in parallel -jobs: - # This workflow contains a single job called "build" - build: - # The type of runner that the job will run on - runs-on: ubuntu-latest - - # Steps represent a sequence of tasks that will be executed as part of the job - steps: - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v2 - - # Sets up python3 - - uses: actions/setup-python@v2 - with: - python-version: 3.x - - # Installs and upgrades pip, installs other dependencies and installs the package from setup.py - - name: "Installs and upgrades pip, installs other dependencies and installs the package from setup.py" - run: | - # Upgrade pip - python3 -m pip install --upgrade pip - # Install build deps - python3 -m pip install setuptools wheel twine - # If requirements.txt exists, install from it - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - # Install the package from setup.py - python3 setup.py install - - # Tests with unittest - - name: Test with unittest - run: | - python3 -m unittest - -# # Upload to TestPyPI -# - name: Build and Upload to TestPyPI -# run: | -# python3 setup.py sdist bdist_wheel -# python3 -m twine upload dist/* -# env: -# TWINE_USERNAME: __token__ -# TWINE_PASSWORD: ${{ secrets.TWINE_TEST_TOKEN }} -# TWINE_REPOSITORY: testpypi From 8416451bf8a2c46048919403dedd2765e6d173df Mon Sep 17 00:00:00 2001 From: zyd Date: Thu, 19 May 2022 05:44:55 +0900 Subject: [PATCH 2/4] fix pre-commit errors --- .github/workflows/upload-to-pip.yml | 4 ++-- setup.py | 3 ++- test/test_divide.py | 1 - test/test_empty.py | 1 - test/test_groupBy.py | 1 - test/test_invoker.py | 1 - test/test_reduceBy.py | 1 - test/test_reject.py | 2 +- 8 files changed, 5 insertions(+), 9 deletions(-) diff --git a/.github/workflows/upload-to-pip.yml b/.github/workflows/upload-to-pip.yml index f758c6b..32a5727 100644 --- a/.github/workflows/upload-to-pip.yml +++ b/.github/workflows/upload-to-pip.yml @@ -1,9 +1,9 @@ name: Upload to PIP -# Controls when the action will run. +# Controls when the action will run. on: # Triggers the workflow when a release is created - release: + release: types: [created] # Allows you to run this workflow manually from the Actions tab workflow_dispatch: diff --git a/setup.py b/setup.py index 245cc0f..c1855e7 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,8 @@ # Fetches the content from README.md # This will be used for the "long_description" field. -README_MD = open(join(dirname(abspath(__file__)), "README.md")).read() +with open(join(dirname(abspath(__file__)), "README.md"), encoding='utf-8') as f: + README_MD = f.read() setup( # The name of your project that we discussed earlier. diff --git a/test/test_divide.py b/test/test_divide.py index 9a5b669..1f849d6 100644 --- a/test/test_divide.py +++ b/test/test_divide.py @@ -1,4 +1,3 @@ -import math import unittest import ramda as R diff --git a/test/test_empty.py b/test/test_empty.py index 957e46b..9f224c5 100644 --- a/test/test_empty.py +++ b/test/test_empty.py @@ -1,5 +1,4 @@ import unittest -from tkinter.messagebox import NO import ramda as R diff --git a/test/test_groupBy.py b/test/test_groupBy.py index 796fc70..02048cc 100644 --- a/test/test_groupBy.py +++ b/test/test_groupBy.py @@ -1,7 +1,6 @@ import unittest import ramda as R -from ramda.private._isTransformer import _isTransformer """ https://github.com/ramda/ramda/blob/master/test/groupBy.js diff --git a/test/test_invoker.py b/test/test_invoker.py index dc87dd4..fde9c28 100644 --- a/test/test_invoker.py +++ b/test/test_invoker.py @@ -2,7 +2,6 @@ import unittest import ramda as R -from ramda.private._helper import funcArgsLength """ https://github.com/ramda/ramda/blob/master/test/invoker.js diff --git a/test/test_reduceBy.py b/test/test_reduceBy.py index 560ba0f..08045f3 100644 --- a/test/test_reduceBy.py +++ b/test/test_reduceBy.py @@ -2,7 +2,6 @@ import unittest import ramda as R -from ramda.private._helper import funcArgsLength """ https://github.com/ramda/ramda/blob/master/test/reduceBy.js diff --git a/test/test_reject.py b/test/test_reject.py index 85f1ca6..16ca792 100644 --- a/test/test_reject.py +++ b/test/test_reject.py @@ -2,7 +2,7 @@ import ramda as R -from .helpers.Maybe import Just, Nothing +from .helpers.Maybe import Just """ https://github.com/ramda/ramda/blob/master/test/reject.js From 5a38ff0f6688fd391c5e667d09be6887b3000445 Mon Sep 17 00:00:00 2001 From: zyd Date: Thu, 19 May 2022 05:50:26 +0900 Subject: [PATCH 3/4] install pylint --- .github/workflows/pr-check.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/pr-check.yml b/.github/workflows/pr-check.yml index 9e77807..428a924 100644 --- a/.github/workflows/pr-check.yml +++ b/.github/workflows/pr-check.yml @@ -30,6 +30,12 @@ jobs: with: python-version: 3.x + # Install dependencies + - name: "Installs dependencies" + run: | + python3 -m pip install --upgrade pip + python3 -m pip install pylint --upgrade + - uses: pre-commit/action@v2.0.3 # Tests with unittest From cc0c2cca1babc2a92fe913a64215b0390cfd70b2 Mon Sep 17 00:00:00 2001 From: zyd Date: Thu, 19 May 2022 05:53:30 +0900 Subject: [PATCH 4/4] change to pytest --- .github/workflows/pr-check.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pr-check.yml b/.github/workflows/pr-check.yml index 428a924..b3cfd91 100644 --- a/.github/workflows/pr-check.yml +++ b/.github/workflows/pr-check.yml @@ -35,10 +35,11 @@ jobs: run: | python3 -m pip install --upgrade pip python3 -m pip install pylint --upgrade + python3 -m pip install pytest --upgrade - uses: pre-commit/action@v2.0.3 - # Tests with unittest - - name: Test with unittest + # Tests with pytest + - name: Test with pytest run: | - python3 -m unittest + pytest