Skip to content

Commit

Permalink
feat(lookup_table): ic, psycopg, xml. ci update (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
kiyoon authored Aug 21, 2024
1 parent 8e4b072 commit 806bc88
Show file tree
Hide file tree
Showing 36 changed files with 137 additions and 605 deletions.
20 changes: 5 additions & 15 deletions .github/workflows/apply-pip-compile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
- uses: deargen/workflows/actions/apply-pip-compile@master
with:
python-version-file: pyproject.toml
- name: Install uv
run: |
pip3 install uv
- name: Run uv pip compile and push
run: |
set +e # Do not exit shell on failure
bash scripts/compile_requirements.sh
git config user.name github-actions[bot]
git config user.email github-actions[bot]@users.noreply.github.com
git add .
git commit -m "build: update requirements using uv pip compile [skip ci]"
git push
pyproject-toml-file: pyproject.toml
requirements-in-dir: deps
requirements-out-dir: deps/lock
python-platforms: x86_64-manylinux_2_28,aarch64-apple-darwin,x86_64-apple-darwin,x86_64-pc-windows-msvc
32 changes: 8 additions & 24 deletions .github/workflows/apply-styles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,17 @@ name: Apply ruff format, isort, and fixes
on:
workflow_dispatch:
inputs:
ruff_select:
ruff-select:
description: 'ruff select'
default: I,D20,D21,UP00,UP032,UP034
ruff_ignore:
ruff-ignore:
description: 'ruff ignore'
default: D212

jobs:
apply-ruff:
name: Apply ruff
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version-file: pyproject.toml
- name: Install ruff
run: |
pip3 install -r <(grep '^ruff==' deps/x86_64-unknown-linux-gnu/requirements_dev.txt)
- name: Run ruff and push
run: |
set +e # Do not exit shell on ruff failure
ruff --select=${{ github.event.inputs.ruff_select }} --ignore=${{ github.event.inputs.ruff_ignore }} --fix --unsafe-fixes .
ruff format .
git config user.name github-actions[bot]
git config user.email github-actions[bot]@users.noreply.github.com
git add .
git commit -m "style: ruff format, isort, fixes [skip ci]"
git push
ruff-format:
uses: deargen/workflows/.github/workflows/apply-ruff.yml@master
with:
ruff-select: ${{ github.event.inputs.ruff-select }}
ruff-ignore: ${{ github.event.inputs.ruff-ignore }}
ruff-version-file: deps/lock/x86_64-manylinux_2_28/requirements_dev.txt
54 changes: 15 additions & 39 deletions .github/workflows/check-pip-compile.yml
Original file line number Diff line number Diff line change
@@ -1,49 +1,25 @@
name: Check pip compile sync

on: [push, pull_request]
on:
push:
branches:
- main
- master
pull_request:

concurrency:
group: ${{github.workflow}}-${{github.ref}}
cancel-in-progress: true

jobs:
check-pip-compile:
name: Check pip compile
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: |
echo "python_version=$(python3 scripts/get_python_version.py)" >> "$GITHUB_OUTPUT"
pip3 install --user uv
id: get-python-version
- name: Set up Python
uses: actions/setup-python@v5
- uses: deargen/workflows/actions/check-pip-compile@master
with:
python-version: ${{ steps.get-python-version.outputs.python_version }}
- name: Install uv
run: |
pip3 install uv
- name: Generate lockfile and print diff
run: |
set +e # Do not exit shell on failure
out=$(bash scripts/compile_requirements.sh 2> _stderr.txt)
exit_code=$?
err=$(<_stderr.txt)
if [[ -n "$out" ]]; then
# Display the raw output in the step
echo "${out}"
# Display the Markdown output in the job summary
{ echo "\`\`\`"; echo "${out}"; echo "\`\`\`"; } >> "$GITHUB_STEP_SUMMARY"
fi
if [[ -n "$err" ]]; then
echo "${err}"
{ echo "\`\`\`"; echo "${err}"; echo "\`\`\`"; } >> "$GITHUB_STEP_SUMMARY"
fi
if [[ $exit_code -eq 0 ]]; then
# When the script fails, there are changes in requirements that are not compiled yet.
# Print the suggested changes.
{ echo "\`\`\`diff"; git diff; echo "\`\`\`"; } >> "$GITHUB_STEP_SUMMARY"
exit 1
fi
# When the script fails, it means it does not have anything to compile.
exit 0
pyproject-toml-file: pyproject.toml
requirements-in-dir: deps
requirements-out-dir: deps/lock
python-platforms: x86_64-manylinux_2_28,aarch64-apple-darwin,x86_64-apple-darwin,x86_64-pc-windows-msvc
89 changes: 16 additions & 73 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,94 +1,37 @@
name: Deploy a new version
name: Commit CHANGELOG.md, create a Release and deploy MkDocs

on:
workflow_dispatch:
inputs:
version_tag:
description: 'Version tag'
version-tag:
description: Version tag
required: true
default: v0.1.0
dry_run:
dry-run:
description: Dry run
type: boolean
description: 'Dry run'
default: false

jobs:
deploy:
commit-changelog-and-release:
uses: deargen/workflows/.github/workflows/commit-changelog-and-release.yml@master
with:
version-tag: ${{ github.event.inputs.version-tag }}
dry-run: ${{ github.event.inputs.dry-run == true }}
changelog-path: docs/CHANGELOG.md
exclude-types: build,docs,style,other

publish-to-pypi:
runs-on: ubuntu-latest
environment: deploy

steps:
- uses: actions/checkout@v4
- name: Push new version tag temporarily for changelog generation
run: |
git config user.name github-actions[bot]
git config user.email github-actions[bot]@users.noreply.github.com
git tag -a ${{ github.event.inputs.version_tag }} -m ${{ github.event.inputs.version_tag }}
git push --tags
- name: (dry-run) Get CHANGELOG
if: ${{ github.event.inputs.dry_run == 'true' }}
id: changelog-dry-run
uses: requarks/changelog-action@v1.10.2
with:
includeInvalidCommits: true
excludeTypes: build,docs,style,other
token: ${{ github.token }}
tag: ${{ github.event.inputs.version_tag }}

- name: (dry-run) Display CHANGELOG
if: ${{ github.event.inputs.dry_run == 'true' }}
run: |
echo '${{ steps.changelog-dry-run.outputs.changes }}'
echo '${{ steps.changelog-dry-run.outputs.changes }}' > "$GITHUB_STEP_SUMMARY"
- name: (dry-run) Remove temporary version tag
if: ${{ github.event.inputs.dry_run == 'true' }}
run: |
git tag -d ${{ github.event.inputs.version_tag }}
git push origin --delete ${{ github.event.inputs.version_tag }}
- name: Update CHANGELOG
if: ${{ github.event.inputs.dry_run == 'false' }}
id: changelog
uses: requarks/changelog-action@v1.10.2
with:
includeInvalidCommits: true
excludeTypes: build,docs,style,other
token: ${{ github.token }}
tag: ${{ github.event.inputs.version_tag }}
changelogFilePath: docs/CHANGELOG.md

- name: Commit docs/CHANGELOG.md and update tag
if: ${{ github.event.inputs.dry_run == 'false' }}
run: |
git tag -d ${{ github.event.inputs.version_tag }}
git push origin --delete ${{ github.event.inputs.version_tag }}
git add docs/CHANGELOG.md
git commit -m "docs: update docs/CHANGELOG.md for ${{ github.event.inputs.version_tag }} [skip ci]"
git tag -a ${{ github.event.inputs.version_tag }} -m ${{ github.event.inputs.version_tag }}
git push
git push --tags
- name: Create Release
if: ${{ github.event.inputs.dry_run == 'false' }}
uses: ncipollo/release-action@v1.14.0
with:
allowUpdates: true
draft: false
makeLatest: true
name: ${{ github.event.inputs.version_tag }}
tag: ${{ github.event.inputs.version_tag }}
body: ${{ steps.changelog.outputs.changes }}

- name: Set up Python 3.11
if: ${{ github.event.inputs.dry_run == 'false' }}
if: ${{ github.event.inputs.dry-run == 'false' }}
uses: actions/setup-python@v4
with:
python-version: 3.11

- name: Build and upload to PyPI
if: ${{ github.event.inputs.dry_run == 'false' }}
if: ${{ github.event.inputs.dry-run == 'false' }}
run: |
python -m pip install --upgrade pip
pip3 install build twine
Expand Down
78 changes: 15 additions & 63 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,67 +1,19 @@
name: Linting

on: [push, pull_request]
on:
push:
branches:
- main
- master
pull_request:

jobs:
ruff:
name: ruff
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version-file: pyproject.toml
- name: Install ruff and requirements
run: |
pip3 install -r <(grep '^ruff==' deps/x86_64-unknown-linux-gnu/requirements_dev.txt)
- name: Run ruff (code annotation)
run: |
set +e # Do not exit shell on ruff failure
ruff check --output-format=github
exit 0
- name: Run ruff (summary)
run: |
set +e # Do not exit shell on ruff failure
nonzero_exit=0
files=$(find . -type f -name "*.py" | sort)
while read -r file; do
out=$(ruff check --force-exclude "$file" 2> ruff_stderr.txt)
exit_code=$?
err=$(<ruff_stderr.txt)
if [[ $exit_code -ne 0 ]]; then
nonzero_exit=$exit_code
fi
concurrency:
group: ${{github.workflow}}-${{github.ref}}
cancel-in-progress: true

if [[ -n "$out" ]]; then
# Display the raw output in the step
echo "${out}"
# Display the Markdown output in the job summary
{ echo "\`\`\`python"; echo "${out}"; echo "\`\`\`"; } >> "$GITHUB_STEP_SUMMARY"
fi
if [[ -n "$err" ]]; then
echo "${err}"
{ echo "\`\`\`python"; echo "${err}"; echo "\`\`\`"; } >> "$GITHUB_STEP_SUMMARY"
fi
out=$(ruff check --diff --force-exclude "$file" 2> ruff_stderr.txt)
err=$(<ruff_stderr.txt)
if [[ -n "$out" ]]; then
# Display the raw output in the step
echo "${out}"
# Display the Markdown output in the job summary
{ echo "\`\`\`python"; echo "${out}"; echo "\`\`\`"; } >> "$GITHUB_STEP_SUMMARY"
fi
if [[ -n "$err" ]]; then
echo "${err}"
{ echo "\`\`\`python"; echo "${err}"; echo "\`\`\`"; } >> "$GITHUB_STEP_SUMMARY"
fi
done <<< "$files"
# Exit with the first non-zero exit-code returned by ruff
# or just zero if all passed
exit ${nonzero_exit}
jobs:
ruff-lint:
uses: deargen/workflows/.github/workflows/check-ruff.yml@master
with:
check-type: lint
ruff-version-file: deps/lock/x86_64-manylinux_2_28/requirements_dev.txt
Loading

0 comments on commit 806bc88

Please sign in to comment.