From bc5bdb47e5fb04f8f941545fcf1a8a4aaaed3155 Mon Sep 17 00:00:00 2001 From: "Erick G. Islas-Osuna" Date: Mon, 24 Jan 2022 11:39:22 -0600 Subject: [PATCH 01/12] feat: pre-commit suggestion In order to keep this as a working project, we can recommend the usage of a pre-commit pipeline in order to just commit code which could be whithin our expectations of "code quality". --- .pre-commit-config.yaml | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..11add27e --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,39 @@ +default_stages: [commit, push] +repos: + - repo: https://github.com/PyCQA/isort + rev: 5.8.0 + hooks: + - id: isort + name: isort (python) + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.0.1 + hooks: + - id: check-added-large-files + - id: debug-statements + - id: double-quote-string-fixer + - id: end-of-file-fixer + - id: mixed-line-ending + - id: check-yaml + - id: requirements-txt-fixer + - id: mixed-line-ending + - id: trailing-whitespace + # - repo: https://github.com/psf/black + # rev: stable + # hooks: + # - id: black + # language_version: python3.8 + - repo: https://github.com/pycqa/isort + rev: 5.10.1 + hooks: + - id: isort + name: isort (python) + - repo: https://github.com/pycqa/flake8 + rev: 3.9.2 + hooks: + - id: flake8 + name: flake8 (python) + - repo: https://github.com/myint/docformatter + rev: v1.4 + hooks: + - id: docformatter + args: ["--wrap-descriptions", "0"] From 5a4e546b2a3b5e34cc7bd9430144f99abaec065b Mon Sep 17 00:00:00 2001 From: "Erick G. Islas-Osuna" Date: Mon, 24 Jan 2022 12:49:47 -0600 Subject: [PATCH 02/12] feat: lint and test jobs --- .github/workflows/code-quality.yml | 47 ++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 .github/workflows/code-quality.yml diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml new file mode 100644 index 00000000..4fb0fe46 --- /dev/null +++ b/.github/workflows/code-quality.yml @@ -0,0 +1,47 @@ +name: Code Quality Checks + +on: + push: + branches-ignore: + - "master" +jobs: + lint: + name: Linting project + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: "3.6" + architecture: x64 + - name: Restoring cache + uses: actions/cache@v2 + with: + path: ./venv + key: ${{ runner.os }}-python-${{ hashFiles('requirements.txt') }} + - name: Create virtual environment + run: . scripts/create_venv.sh + - name: Check code style + run: . scripts/lint.sh + test: + name: Testing project + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: "3.6" + architecture: x64 + - name: Restoring cache + uses: actions/cache@v2 + with: + path: ./venv + key: ${{ runner.os }}-python-${{ hashFiles('requirements.txt') }} + - name: Create virtual environment + run: . scripts/create_venv.sh + - name: Install package + run: . scripts/helpers.sh && install_package [devel] + - name: Run tests + run: . scripts/run_tests.sh From f7b48dc95055cee795f03050cead92906e6a698d Mon Sep 17 00:00:00 2001 From: "Erick G. Islas-Osuna" Date: Mon, 24 Jan 2022 13:07:33 -0600 Subject: [PATCH 03/12] feat: dependabot to keep everything updated --- .github/dependabot.yaml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .github/dependabot.yaml diff --git a/.github/dependabot.yaml b/.github/dependabot.yaml new file mode 100644 index 00000000..b38df29f --- /dev/null +++ b/.github/dependabot.yaml @@ -0,0 +1,6 @@ +version: 2 +updates: + - package-ecosystem: "pip" + directory: "/" + schedule: + interval: "daily" From ab5b6d6a1255fb2d511d60fe58ce077137f0108e Mon Sep 17 00:00:00 2001 From: "Erick G. Islas-Osuna" Date: Mon, 24 Jan 2022 14:15:17 -0600 Subject: [PATCH 04/12] fix: python location --- scripts/create_venv.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/create_venv.sh b/scripts/create_venv.sh index 9260f299..6d31858e 100644 --- a/scripts/create_venv.sh +++ b/scripts/create_venv.sh @@ -5,7 +5,7 @@ set -e cur_dir=$(dirname ${BASH_SOURCE[0]}) source $cur_dir/helpers.sh -/usr/local/bin/python3 -m venv venv +python3 -m venv venv activate_venv From 51a5dfd8e8852f4d287df2ad700dd9da8b548b26 Mon Sep 17 00:00:00 2001 From: "Erick G. Islas-Osuna" Date: Mon, 24 Jan 2022 14:40:44 -0600 Subject: [PATCH 05/12] feat: type and pip checking --- .github/workflows/code-quality.yml | 56 ++++++++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 3 deletions(-) diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml index 4fb0fe46..99ae256a 100644 --- a/.github/workflows/code-quality.yml +++ b/.github/workflows/code-quality.yml @@ -2,11 +2,11 @@ name: Code Quality Checks on: push: - branches-ignore: + branches: - "master" jobs: lint: - name: Linting project + name: Linter runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -25,7 +25,9 @@ jobs: - name: Check code style run: . scripts/lint.sh test: - name: Testing project + name: Run tests + needs: + - "lint" runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -45,3 +47,51 @@ jobs: run: . scripts/helpers.sh && install_package [devel] - name: Run tests run: . scripts/run_tests.sh + type-check: + name: Mypy check + needs: + - "lint" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: "3.6" + architecture: x64 + - name: Restoring cache + uses: actions/cache@v2 + with: + path: ./venv + key: ${{ runner.os }}-python-${{ hashFiles('requirements.txt') }} + - name: Create virtual environment + run: . scripts/create_venv.sh + - name: Install package + run: . scripts/helpers.sh && install_package [devel] + - name: Run type checking + run: . scripts/run_type_check.sh + pip-check: + name: Pip check + needs: + - "lint" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: "3.6" + architecture: x64 + - name: Restoring cache + uses: actions/cache@v2 + with: + path: ./venv + key: ${{ runner.os }}-python-${{ hashFiles('requirements.txt') }} + - name: Create virtual environment + run: . scripts/create_venv.sh + - name: Install package + run: . scripts/helpers.sh && install_package [devel] + - name: Run pip check + run: . scripts/helpers.sh \ + activate_venv \ + pip check From 886315af341f723ece7f727297de02ca4ed55c2e Mon Sep 17 00:00:00 2001 From: "Erick G. Islas-Osuna" Date: Mon, 24 Jan 2022 15:42:23 -0600 Subject: [PATCH 06/12] fix: code quality runs on every branch except main --- .github/workflows/code-quality.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml index 99ae256a..10808ecd 100644 --- a/.github/workflows/code-quality.yml +++ b/.github/workflows/code-quality.yml @@ -2,7 +2,7 @@ name: Code Quality Checks on: push: - branches: + branches-ignore: - "master" jobs: lint: From c71015352aa87218910f2e933993f5f1150a4818 Mon Sep 17 00:00:00 2001 From: "Erick G. Islas-Osuna" Date: Mon, 24 Jan 2022 16:05:31 -0600 Subject: [PATCH 07/12] wip: build and release workflows --- .github/workflows/build-and-release.yml | 88 +++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 .github/workflows/build-and-release.yml diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml new file mode 100644 index 00000000..149fb976 --- /dev/null +++ b/.github/workflows/build-and-release.yml @@ -0,0 +1,88 @@ +name: Code Quality Checks + +on: + push: + branches: + - "master" + tags: + - "**" + +jobs: + build: + name: Build package + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: "3.6" + architecture: x64 + - name: Restoring cache + uses: actions/cache@v2 + with: + path: ./venv + key: ${{ runner.os }}-python-${{ hashFiles('requirements.txt') }} + - name: Create virtual environment + run: . scripts/create_venv.sh + - name: Build package + run: . scripts/build.sh + - name: Store build artifacts + uses: actions/upload-artifact@v2 + with: + name: stored-package + path: dist + build-docs: + name: Build documentation + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: "3.6" + architecture: x64 + - name: Restoring cache + uses: actions/cache@v2 + with: + path: ./venv + key: ${{ runner.os }}-python-${{ hashFiles('requirements.txt') }} + - name: Create virtual environment + run: . scripts/create_venv.sh + - name: Install pandoc + run: sudo apt-get install -y pandoc + - name: Install package + run: . scripts/helper.sh \ + install_package [devel] + - name: Build documentation + run: . scripts/build_docs.sh + + # TODO: Maybe we can add here an artifact for the build-docs step? + release: + name: Release package + runs-on: ubuntu-latest + needs: + - "build" + - "build-docs" + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: "3.6" + architecture: x64 + - name: Restoring cache + uses: actions/cache@v2 + with: + path: ./venv + key: ${{ runner.os }}-python-${{ hashFiles('requirements.txt') }} + - name: Create virtual environment + run: . scripts/create_venv.sh + - name: Init .pypirc + run: . scripts/init_pypirc.sh + - name: Download a single artifact + uses: actions/download-artifact@v2 + with: + name: stored-package + - name: Release package + run: . scripts/release.sh dist From 846781c288768dba23c14b73efa0f9d80329a750 Mon Sep 17 00:00:00 2001 From: "Erick G. Islas-Osuna" Date: Tue, 25 Jan 2022 09:44:36 -0600 Subject: [PATCH 08/12] feat: add build docs to code-quality workflow Also, add the usage of secrets as environment vars for tags. --- .github/workflows/build-and-release.yml | 32 +++---------------------- .github/workflows/code-quality.yml | 26 ++++++++++++++++++++ 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 149fb976..1ff6b1c8 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -2,8 +2,6 @@ name: Code Quality Checks on: push: - branches: - - "master" tags: - "**" @@ -32,38 +30,11 @@ jobs: with: name: stored-package path: dist - build-docs: - name: Build documentation - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: "3.6" - architecture: x64 - - name: Restoring cache - uses: actions/cache@v2 - with: - path: ./venv - key: ${{ runner.os }}-python-${{ hashFiles('requirements.txt') }} - - name: Create virtual environment - run: . scripts/create_venv.sh - - name: Install pandoc - run: sudo apt-get install -y pandoc - - name: Install package - run: . scripts/helper.sh \ - install_package [devel] - - name: Build documentation - run: . scripts/build_docs.sh - - # TODO: Maybe we can add here an artifact for the build-docs step? release: name: Release package runs-on: ubuntu-latest needs: - "build" - - "build-docs" steps: - uses: actions/checkout@v2 - name: Set up Python @@ -79,6 +50,9 @@ jobs: - name: Create virtual environment run: . scripts/create_venv.sh - name: Init .pypirc + env: + PYPI_USER: ${{ secrets.PYPI_USER }} + PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }} run: . scripts/init_pypirc.sh - name: Download a single artifact uses: actions/download-artifact@v2 diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml index 10808ecd..6eeaa6f7 100644 --- a/.github/workflows/code-quality.yml +++ b/.github/workflows/code-quality.yml @@ -95,3 +95,29 @@ jobs: run: . scripts/helpers.sh \ activate_venv \ pip check + build-docs: + name: Build documentation + needs: + - "lint" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: "3.6" + architecture: x64 + - name: Restoring cache + uses: actions/cache@v2 + with: + path: ./venv + key: ${{ runner.os }}-python-${{ hashFiles('requirements.txt') }} + - name: Create virtual environment + run: . scripts/create_venv.sh + - name: Install pandoc + run: sudo apt-get install -y pandoc + - name: Install package + run: . scripts/helper.sh \ + install_package [devel] + - name: Build documentation + run: . scripts/build_docs.sh From d78042c0b86b3002634d2132d31405753eafc372 Mon Sep 17 00:00:00 2001 From: "Erick G. Islas-Osuna" Date: Tue, 25 Jan 2022 09:48:12 -0600 Subject: [PATCH 09/12] fix: typo --- .github/workflows/code-quality.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml index 6eeaa6f7..8080ddc0 100644 --- a/.github/workflows/code-quality.yml +++ b/.github/workflows/code-quality.yml @@ -117,7 +117,7 @@ jobs: - name: Install pandoc run: sudo apt-get install -y pandoc - name: Install package - run: . scripts/helper.sh \ + run: . scripts/helpers.sh \ install_package [devel] - name: Build documentation run: . scripts/build_docs.sh From cbb1af4fa75b89c6495de90a4b73aa974f249f3c Mon Sep 17 00:00:00 2001 From: "Erick G. Islas-Osuna" Date: Fri, 28 Jan 2022 00:52:26 -0600 Subject: [PATCH 10/12] fix: build docs --- .circleci/config.yml | 199 ------------------------ .github/workflows/build-and-release.yml | 2 +- .github/workflows/code-quality.yml | 9 +- 3 files changed, 4 insertions(+), 206 deletions(-) delete mode 100644 .circleci/config.yml diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 05cee8e1..00000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,199 +0,0 @@ -.common-values: - - docker-image: &docker-image circleci/python:3.6 - - working_directory: &working-directory ~/repo - - # Download and cache dependencies - restore-cache: &restore-cache - keys: - - v1-dependencies-{{ checksum "requirements.txt" }} - - create-venv: &create-venv - name: Create virtualenv - command: . scripts/create_venv.sh - - save-cache: &save-cache - paths: - - ./venv - key: v1-dependencies-{{ checksum "requirements.txt" }} - - install-package: &install-package - name: Install package - command: | - . scripts/helpers.sh - install_package [devel] - - install-pandoc: &install-pandoc - name: Install pandoc - command: sudo apt-get install pandoc - -.master-branch-filter: &master-branch-filter - filters: - branches: - ignore: master - -.requires-lint: &requires-lint - requires: - - lint - <<: *master-branch-filter - -.tags-only-filter: &tags-only-filter - filters: - branches: - ignore: /.*/ - tags: - only: /.*/ - -.requires-build: &requires-build - requires: - - build - <<: *tags-only-filter - -.lint-steps: &lint-steps - docker: - - image: *docker-image - working_directory: *working-directory - steps: - - checkout - - restore_cache: *restore-cache - - run: *create-venv - - run: - name: Check code style (PEP8) - command: . scripts/lint.sh - - save_cache: *save-cache - - -.test-steps: &test-steps - docker: - - image: *docker-image - working_directory: *working-directory - steps: - - checkout - - restore_cache: *restore-cache - - run: *create-venv - - save_cache: *save-cache - - run: *install-package - - run: - name: Run tests - command: . scripts/run_tests.sh - -.pip-check: &pip-check - docker: - - image: *docker-image - working_directory: *working-directory - steps: - - checkout - - restore_cache: *restore-cache - - run: *create-venv - - save_cache: *save-cache - - run: *install-package - - run: - name: Run pip check - command: | - . scripts/helpers.sh - activate_venv - pip check - -.build: &build - docker: - - image: *docker-image - working_directory: *working-directory - steps: - - checkout - - restore_cache: *restore-cache - - run: *create-venv - - save_cache: *save-cache - - run: - name: Build package - command: . scripts/build.sh - - persist_to_workspace: - root: ~/repo - paths: - - dist - -.build-docs: &build-docs - docker: - - image: *docker-image - working_directory: *working-directory - steps: - - checkout - - restore_cache: *restore-cache - - run: *create-venv - - save_cache: *save-cache - - run: *install-pandoc - - run: *install-package - - run: - name: Build documentation - command: . scripts/build_docs.sh - -.release: &release - docker: - - image: *docker-image - working_directory: *working-directory - steps: - - attach_workspace: - at: /tmp/package - - checkout - - restore_cache: *restore-cache - - run: *create-venv - - save_cache: *save-cache - - run: - name: init .pypirc - command: . scripts/init_pypirc.sh - - run: - name: Release package - command: . scripts/release.sh /tmp/package/dist - -.type-check: &type-check - docker: - - image: *docker-image - working_directory: *working-directory - steps: - - checkout - - restore_cache: *restore-cache - - run: *create-venv - - save_cache: *save-cache - - run: *install-package - - run: - name: Run type tests - command: . scripts/run_type_check.sh - -version: 2 -jobs: - lint: - <<: *lint-steps - test: - <<: *test-steps - pip-check: - <<: *pip-check - build: - <<: *build - build-docs: - <<: *build-docs - release: - <<: *release - type-check: - <<: *type-check - - -workflows: - version: 2 - test-all: - jobs: - - lint: - <<: *master-branch-filter - - test: - <<: *requires-lint - - pip-check: - <<: *requires-lint - - type-check: - <<: *requires-lint - - build-docs: - <<: *requires-lint - build-and-release: - jobs: - - build: - <<: *tags-only-filter - - release: - <<: *requires-build diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 1ff6b1c8..95842883 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -1,4 +1,4 @@ -name: Code Quality Checks +name: build-and-release on: push: diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml index 8080ddc0..9cff7dbd 100644 --- a/.github/workflows/code-quality.yml +++ b/.github/workflows/code-quality.yml @@ -92,9 +92,7 @@ jobs: - name: Install package run: . scripts/helpers.sh && install_package [devel] - name: Run pip check - run: . scripts/helpers.sh \ - activate_venv \ - pip check + run: . scripts/helpers.sh && activate_venv && pip check build-docs: name: Build documentation needs: @@ -115,9 +113,8 @@ jobs: - name: Create virtual environment run: . scripts/create_venv.sh - name: Install pandoc - run: sudo apt-get install -y pandoc + run: sudo apt-get install -y -qq pandoc - name: Install package - run: . scripts/helpers.sh \ - install_package [devel] + run: . scripts/helpers.sh && install_package [devel] - name: Build documentation run: . scripts/build_docs.sh From 3854b75f0f73460ee6f6ac888a1a9f307cb6c5b9 Mon Sep 17 00:00:00 2001 From: "Erick G. Islas-Osuna" Date: Tue, 8 Feb 2022 13:35:54 -0600 Subject: [PATCH 11/12] fix: pre-commit config --- .pre-commit-config.yaml | 10 ---------- scripts/create_venv.sh | 2 +- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 11add27e..7a6017e6 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,16 +17,6 @@ repos: - id: requirements-txt-fixer - id: mixed-line-ending - id: trailing-whitespace - # - repo: https://github.com/psf/black - # rev: stable - # hooks: - # - id: black - # language_version: python3.8 - - repo: https://github.com/pycqa/isort - rev: 5.10.1 - hooks: - - id: isort - name: isort (python) - repo: https://github.com/pycqa/flake8 rev: 3.9.2 hooks: diff --git a/scripts/create_venv.sh b/scripts/create_venv.sh index 6d31858e..8c837c9d 100644 --- a/scripts/create_venv.sh +++ b/scripts/create_venv.sh @@ -5,7 +5,7 @@ set -e cur_dir=$(dirname ${BASH_SOURCE[0]}) source $cur_dir/helpers.sh -python3 -m venv venv +/usr/bin/env python3 -m venv venv activate_venv From 20df957869ba43dbb7d480e2c6c62ba54250befe Mon Sep 17 00:00:00 2001 From: "Erick G. Islas-Osuna" Date: Tue, 22 Mar 2022 10:31:57 -0600 Subject: [PATCH 12/12] add tests for python3.9 --- .github/workflows/code-quality.yml | 37 ++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml index 9cff7dbd..04ebd197 100644 --- a/.github/workflows/code-quality.yml +++ b/.github/workflows/code-quality.yml @@ -25,27 +25,50 @@ jobs: - name: Check code style run: . scripts/lint.sh test: - name: Run tests + name: run tests in python3.9 needs: - "lint" runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Set up Python + - name: set up python uses: actions/setup-python@v2 with: python-version: "3.6" architecture: x64 - - name: Restoring cache + - name: restoring cache uses: actions/cache@v2 with: path: ./venv - key: ${{ runner.os }}-python-${{ hashFiles('requirements.txt') }} - - name: Create virtual environment + key: ${{ runner.os }}-python-${{ hashfiles('requirements.txt') }} + - name: create virtual environment run: . scripts/create_venv.sh - - name: Install package + - name: install package + run: . scripts/helpers.sh && install_package [devel] + - name: run tests + run: . scripts/run_tests.sh + test-py39: + name: run tests + needs: + - "lint" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: set up python + uses: actions/setup-python@v2 + with: + python-version: "3.9" + architecture: x64 + - name: restoring cache + uses: actions/cache@v2 + with: + path: ./venv + key: ${{ runner.os }}-python-${{ hashfiles('requirements.txt') }} + - name: create virtual environment + run: . scripts/create_venv.sh + - name: install package run: . scripts/helpers.sh && install_package [devel] - - name: Run tests + - name: run tests run: . scripts/run_tests.sh type-check: name: Mypy check