Skip to content

Commit

Permalink
chore/#616/modernize deps (#621)
Browse files Browse the repository at this point in the history
* chore: update dependencies, use ruff

* fix: lint fixes, thanks ruff

* chore: update gha workflows
  • Loading branch information
tconbeer authored Jul 26, 2024
1 parent 3ceb7e7 commit 0effe6d
Show file tree
Hide file tree
Showing 42 changed files with 477 additions and 441 deletions.
68 changes: 0 additions & 68 deletions .github/workflows/codeql-analysis.yml

This file was deleted.

41 changes: 33 additions & 8 deletions .github/workflows/primer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,54 @@ jobs:
primer:
name: sqlfmt primer
runs-on: ubuntu-latest
env:
POETRY_VIRTUALENVS_IN_PROJECT: 1
POETRY_INSTALLER_PARALLEL: 1
POETRY_VIRTUALENVS_CREATE: 1

steps:
- name: Check out Repo
uses: actions/checkout@v4
- name: Set up Python 3.10
with:
persist-credentials: false

- name: Set up Python 3.8
uses: actions/setup-python@v5
id: setup-python
with:
python-version: "3.8"

- name: Load cached Poetry installation
id: cached-poetry-install
uses: actions/cache@v4
with:
python-version: "3.10"
path: ~/.local
key: ${{ runner.os }}-poetry-183 # increment to reset cache

- name: Add cached Poetry to PATH
if: steps.cached-poetry-install.outputs.cache-hit == 'true'
run: echo "$HOME/.local/bin" >> $GITHUB_PATH

- name: Install Poetry
if: steps.cached-poetry-install.outputs.cache-hit != 'true'
uses: snok/install-poetry@v1
with:
version: 1.2.2
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
version: 1.8.3

- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v4
with:
path: .venv
key: primer-venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
key: static-venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}

- name: Install python dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --sync --all-extras --no-interaction --only main
run: |
poetry env use ${{ steps.setup-python.outputs.python-version }}
poetry install --sync --all-extras --no-interaction --only main
poetry env info
- name: Run primer
run: |
source .venv/bin/activate
Expand Down
43 changes: 33 additions & 10 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,56 @@ jobs:
publish-package:
if: ${{ github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'release/v') }}
runs-on: ubuntu-latest
environment: publish
env:
POETRY_VIRTUALENVS_IN_PROJECT: 1
POETRY_INSTALLER_PARALLEL: 1
POETRY_VIRTUALENVS_CREATE: 1
permissions:
id-token: write

steps:
- name: Check out sqlfmt main branch
- name: Check out project main branch
uses: actions/checkout@v4
with:
ref: main

- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.10"

- name: Load cached Poetry installation
id: cached-poetry-install
uses: actions/cache@v4
with:
path: ~/.local
key: ${{ runner.os }}-poetry-183 # increment to reset cache

- name: Add cached Poetry to PATH
if: steps.cached-poetry-install.outputs.cache-hit == 'true'
run: echo "$HOME/.local/bin" >> $GITHUB_PATH

- name: Install Poetry
if: steps.cached-poetry-install.outputs.cache-hit != 'true'
uses: snok/install-poetry@v1
with:
version: 1.2.2
- name: Configure poetry
run: poetry config --no-interaction pypi-token.pypi ${{ secrets.SQLFMT_PYPI_TOKEN }}
- name: Get sqlfmt Version
id: sqlfmt_version
run: echo "sqlfmt_version=$(poetry version --short)" >> $GITHUB_OUTPUT
version: 1.8.3

- name: Get project Version
id: project_version
run: echo "project_version=$(poetry version --short)" >> $GITHUB_OUTPUT

- name: Build package
run: poetry build --no-interaction

- name: Publish package to PyPI
run: poetry publish --no-interaction
uses: pypa/gh-action-pypi-publish@release/v1

- name: Create a Github Release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ steps.sqlfmt_version.outputs.sqlfmt_version }}
tag_name: v${{ steps.project_version.outputs.project_version }}
target_commitish: main
token: ${{ secrets.SQLFMT_RELEASE_TOKEN }}
body_path: CHANGELOG.md
Expand Down Expand Up @@ -67,4 +90,4 @@ jobs:
push: true
tags: |
ghcr.io/${{ github.repository }}:latest
ghcr.io/${{ github.repository }}:v${{ steps.sqlfmt_version.outputs.sqlfmt_version }}
ghcr.io/${{ github.repository }}:v${{ steps.project_version.outputs.project_version }}
33 changes: 30 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,38 +10,65 @@ on:
jobs:
prepare-release:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
env:
POETRY_VIRTUALENVS_IN_PROJECT: 1
POETRY_INSTALLER_PARALLEL: 1
POETRY_VIRTUALENVS_CREATE: 1

steps:
- name: Check out sqlfmt main branch
- name: Check out project main branch
uses: actions/checkout@v4
with:
ref: main

- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.10"

- name: Load cached Poetry installation
id: cached-poetry-install
uses: actions/cache@v4
with:
path: ~/.local
key: ${{ runner.os }}-poetry-171 # increment to reset cache

- name: Add cached Poetry to PATH
if: steps.cached-poetry-install.outputs.cache-hit == 'true'
run: echo "$HOME/.local/bin" >> $GITHUB_PATH

- name: Install Poetry
if: steps.cached-poetry-install.outputs.cache-hit != 'true'
uses: snok/install-poetry@v1
with:
version: 1.2.2
version: 1.8.3

- name: Create release branch
run: |
git checkout -b release/v${{ github.event.inputs.newVersion }}
git push --set-upstream origin release/v${{ github.event.inputs.newVersion }}
- name: Bump version
run: poetry version ${{ github.event.inputs.newVersion }} --no-interaction

- name: Ensure package can be built
run: poetry build --no-interaction

- name: Update CHANGELOG
uses: thomaseizinger/keep-a-changelog-new-release@v3
with:
version: ${{ github.event.inputs.newVersion }}

- name: Commit Changes
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Bumps version to ${{ github.event.inputs.newVersion }}

- name: Create pull request into main
uses: thomaseizinger/create-pull-request@1.3.1
uses: thomaseizinger/create-pull-request@1.4.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
Expand Down
46 changes: 33 additions & 13 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,37 +10,57 @@ concurrency:

jobs:
static:
name: Static Analysis - 3.10
name: Static Analysis - 3.8
runs-on: ubuntu-latest
env:
POETRY_VIRTUALENVS_IN_PROJECT: 1
POETRY_INSTALLER_PARALLEL: 1
POETRY_VIRTUALENVS_CREATE: 1
steps:
- name: Check out Repo
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Set up Python 3.10

- name: Set up Python 3.8
uses: actions/setup-python@v5
id: setup-python
with:
python-version: "3.10"
python-version: "3.8"

- name: Load cached Poetry installation
id: cached-poetry-install
uses: actions/cache@v4
with:
path: ~/.local
key: ${{ runner.os }}-poetry-183 # increment to reset cache

- name: Add cached Poetry to PATH
if: steps.cached-poetry-install.outputs.cache-hit == 'true'
run: echo "$HOME/.local/bin" >> $GITHUB_PATH

- name: Install Poetry
if: steps.cached-poetry-install.outputs.cache-hit != 'true'
uses: snok/install-poetry@v1
with:
version: 1.2.2
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
version: 1.8.3

- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v4
with:
path: .venv
key: static-venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}

- name: Install python dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --sync --no-interaction --all-extras --without dev
run: |
poetry env use ${{ steps.setup-python.outputs.python-version }}
poetry install --sync --no-interaction --all-extras --without dev
poetry env info
- name: Run analysis
run: |
source .venv/bin/activate
isort . --check
black . --check
flake8 .
mypy .
poetry run ruff format . --diff
poetry run ruff check .
poetry run mypy --no-incremental
Loading

0 comments on commit 0effe6d

Please sign in to comment.