From 6af0426edbb705cc225c1b83b835b96f16bc1e52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Ribeiro?= Date: Tue, 20 Feb 2024 12:52:06 -0300 Subject: [PATCH] refactor ci --- .github/workflows/ci.yml | 42 ++++++++++++++++++ .github/workflows/ci_core.yml | 19 -------- .github/workflows/python_reusable.yml | 64 --------------------------- .github/workflows/top_level.yml | 54 ---------------------- 4 files changed, 42 insertions(+), 137 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .github/workflows/ci_core.yml delete mode 100644 .github/workflows/python_reusable.yml delete mode 100644 .github/workflows/top_level.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..be76cd4 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,42 @@ +--- +name: CI +on: + workflow_dispatch: + pull_request: + push: + branches: main # Comment this line if you want to test the CI before opening a PR + +jobs: + ci: + runs-on: ubuntu-22.04 + timeout-minutes: 10 + + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + - name: Install Poetry + run: | + pipx install poetry + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version-file: ${{ github.workspace }}/.python-version + cache: poetry + cache-dependency-path: poetry.lock + - name: Install dependencies + run: | + poetry install + + - name: Typecheck + run: | + pyright . + + - name: Lint + run: | + ruff check . + + - name: Test + run: | + python3 -m pytest tests/ \ No newline at end of file diff --git a/.github/workflows/ci_core.yml b/.github/workflows/ci_core.yml deleted file mode 100644 index 4b77f85..0000000 --- a/.github/workflows/ci_core.yml +++ /dev/null @@ -1,19 +0,0 @@ ---- -name: CI libs/core - -on: - pull_request: - paths: - - '.github/workflows/python_reusable.yml' - - '.github/workflows/ci_base.yml' - - 'cow_py/**' - - 'tests/**' - workflow_dispatch: # Allows to trigger the workflow manually in GitHub UI - -jobs: - ci-libs-core: - uses: - ./.github/workflows/python_reusable.yml - with: - working-directory: ./ - secrets: inherit diff --git a/.github/workflows/python_reusable.yml b/.github/workflows/python_reusable.yml deleted file mode 100644 index 975d6f1..0000000 --- a/.github/workflows/python_reusable.yml +++ /dev/null @@ -1,64 +0,0 @@ ---- -name: Reusable Python library CI - -on: - workflow_call: - inputs: - working-directory: - required: true - type: string - description: "From which folder this pipeline executes" - install-packages: - description: "Space seperated list of packages to install using apt-get." - default: "" - type: string - # To avoid being billed 360 minutes if a step does not terminate - # (we've seen the setup-python step below do so!) - ci-timeout: - description: "The timeout of the ci job. Default is 25min" - default: 25 - type: number - -jobs: - local-ci-py-template: - runs-on: ubuntu-22.04 - timeout-minutes: 30 - - defaults: - run: - working-directory: ${{ inputs.working-directory }} - - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - token: ${{ secrets.GITHUB_TOKEN }} - - - name: Setup Python - uses: actions/setup-python@v4 - timeout-minutes: 5 - with: - python-version-file: ${{ github.workspace }}/.python-version - cache: "pip" - cache-dependency-path: | - dev-requirements.txt - pip-requirements.txt - ${{ inputs.working-directory }}/requirements.txt - - - name: Install extra packages - if: ${{ inputs.install-packages != ''}} - run: | - sudo apt-get install -y ${{ inputs.install-packages }} - - - name: Install Python dependencies - run: | - pip install -r "$(git rev-parse --show-toplevel)/pip-requirements.txt" - pip install -r "$(git rev-parse --show-toplevel)/dev-requirements.txt" -r requirements.txt - - - name: Typecheck - run: | - pyright . - - - name: Test - run: | - python3 -m pytest tests/ # Assume that tests are in folder "tests/" diff --git a/.github/workflows/top_level.yml b/.github/workflows/top_level.yml deleted file mode 100644 index e92818d..0000000 --- a/.github/workflows/top_level.yml +++ /dev/null @@ -1,54 +0,0 @@ ---- -name: Top-level CI -on: - workflow_dispatch: - pull_request: - push: - branches: main # Comment this line if you want to test the CI before opening a PR - -jobs: - ci-global: - runs-on: ubuntu-22.04 - timeout-minutes: 10 - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Setup Python - uses: actions/setup-python@v4 - timeout-minutes: 5 - with: - python-version-file: .python-version - cache: 'pip' - cache-dependency-path: | - pip-requirements.txt - dev-requirements.txt - - - name: Install Python dependencies - run: | - pip install -r pip-requirements.txt - pip install -r dev-requirements.txt - - # in order to test the template as well, we create a temporary library in the CI - - name: Create library with template - run: | - cookiecutter --no-input templates/pylibrary --output-dir libs/ - git add libs/library_name # So that checks below apply to generated library - - - name: Format Python imports - run: | - isort --check-only $(git ls-files "*.py") - - - name: Format Python - run: | - black --check $(git ls-files "*.py") - - - name: Lint Python - run: | - flake8 $(git ls-files "*.py") - - # Are all public symbols documented? (see top-level pyproject.toml configuration) - - name: Lint Python doc - run: | - pylint $(git ls-files "*.py")