Skip to content

Commit

Permalink
Merge pull request #34 from spraakbanken/33-rename-project-to-inclue-…
Browse files Browse the repository at this point in the history
…model-name

rename project
  • Loading branch information
kod-kristoff authored Mar 22, 2024
2 parents b11d0a7 + 9ae225f commit 48b7c33
Show file tree
Hide file tree
Showing 25 changed files with 1,421 additions and 940 deletions.
14 changes: 10 additions & 4 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ concurrency:
jobs:
fmt:
runs-on: ubuntu-latest
name: ubuntu / fmt
name: ubuntu / 3.9 / fmt
steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Set up the python ${{ env.MINIMUM_PYTHON_VERSION }}
uses: pdm-project/setup-pdm@v4
Expand All @@ -47,9 +49,11 @@ jobs:
run: make check-fmt
lint:
runs-on: ubuntu-latest
name: ubuntu / lint
name: ubuntu / 3.9 / lint
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Set up the python ${{ env.MINIMUM_PYTHON_VERSION }}
uses: pdm-project/setup-pdm@v4
id: setup-python
Expand All @@ -68,9 +72,11 @@ jobs:
run: make lint
type-check:
runs-on: ubuntu-latest
name: ubuntu / type-check
name: ubuntu / 3.9 / type-check
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Set up the python ${{ env.MINIMUM_PYTHON_VERSION }}
uses: pdm-project/setup-pdm@v4
id: setup-python
Expand All @@ -86,7 +92,7 @@ jobs:
if: steps.cached-venv.outputs.cache-hit != 'true'
run: make install-dev
- name: type-check code
run: make lint
run: make type-check

# https://github.com/marketplace/actions/alls-green#why used for branch protection checks
check-check:
Expand Down
136 changes: 136 additions & 0 deletions .github/workflows/release-viklofg-sweocr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
name: release

on:
push:
branches:
- main
tags:
- 'ocr-correction-viklofg-sweocr-v[0-9]+.[0-9]+.[0-9]+'
pull_request:
merge_group:

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
permissions:
contents: read

env:
MINIMUM_PYTHON_VERSION: "3.9"

jobs:
build:
# This action builds distribution files for upload to PyPI

name: ubuntu / 3.9 / build
runs-on: ubuntu-latest
steps:
#----------------------------------------------
# check-out repo and set-up python
#----------------------------------------------
- name: Check out repository
uses: actions/checkout@v4
with:
submodules: true

#----------------------------------------------
# ----- setup python -----
#----------------------------------------------
- name: Set up the environment
uses: pdm-project/setup-pdm@v4
id: setup-python
with:
python-version: ${{ env.MINIMUM_PYTHON_VERSION }}

#----------------------------------------------
# ----- build distribution -----
#----------------------------------------------
- name: Build distribution
run: cd ocr-correction-viklofg-sweocr && make build

#----------------------------------------------
# ----- upload artifacts -----
#----------------------------------------------
- uses: actions/upload-artifact@v4
with:
name: pypi_files
path: ocr-correction-viklofg-sweocr/dist

test-build:
# This action runs the test suite on the built artifact in the `build` action.
# The default is to run this in ubuntu, macos and windows

name: ${{ matrix.os }} / 3.9 / test built artifact
needs: [build]

strategy:
fail-fast: false
matrix:
os:
- ubuntu

runs-on: ${{ matrix.os }}-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: set up python
uses: actions/setup-python@v5
with:
python-version: ${{ env.MINIMUM_PYTHON_VERSION }}

- name: get dist artifacts
uses: actions/download-artifact@v4
with:
name: pypi_files
path: dist

- run: rm -r ocr-correction-viklofg-sweocr/src
- run: pip install typing-extensions
- run: pip install -r ocr-correction-viklofg-sweocr/tests/requirements-testing.lock
- run: pip install sparv-sbx-ocr-correction-viklofg-sweocr --no-index --no-deps --find-links dist --force-reinstall
- run: pytest ocr-correction-viklofg-sweocr/tests

# https://github.com/marketplace/actions/alls-green#why used for branch protection checks
release-check:
if: always()
needs:
- build
- test-build
runs-on: ubuntu-latest
permissions: {}
steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}
# allowed-failures: coverage

publish:
# This action publishes the built and tested artifact to PyPI, but only on a tag

needs:
- test-build
if: success() && startsWith(github.ref, 'refs/tags/ocr-correction-viklofg-sweocr-v')
runs-on: ubuntu-latest
environment: release
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python ${{ env.MINIMUM_PYTHON_VERSION }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.MINIMUM_PYTHON_VERSION }}
- name: get dist artifacts
uses: actions/download-artifact@v4
with:
name: pypi_files
path: dist

- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
4 changes: 4 additions & 0 deletions .github/workflows/scheduled.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ jobs:
name: ubuntu / 3.13-dev
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install pdm
uses: pdm-project/setup-pdm@v4
with:
Expand Down Expand Up @@ -54,6 +56,8 @@ jobs:
# steps, so we repeat it.
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install 3.12
if: hashFiles('pdm.lock') != ''
uses: pdm-project/setup-pdm@v4
Expand Down
102 changes: 9 additions & 93 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ env:
jobs:

coverage:
# This action runs tests for coverage collection and uploads them to codecov.io.
# This requires the secret `CODECOV_TOKEN` be set as secret on GitHub, both for
# Actions and Dependabot

name: "${{ matrix.os }} / ${{ matrix.python-version }} / coverage"
strategy:
max-parallel: 4
Expand All @@ -39,6 +43,8 @@ jobs:
PYTHON: ${{ matrix.python-version }}
steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Set up the environment
uses: pdm-project/setup-pdm@v4
Expand Down Expand Up @@ -84,6 +90,8 @@ jobs:
name: ubuntu / 3.9 / minimal-versions
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Set up the environment
uses: pdm-project/setup-pdm@v4
id: setup-python
Expand Down Expand Up @@ -127,7 +135,7 @@ jobs:
- name: Run example
run: |
source .venv/bin/activate
cd examples/hello-ocr
cd examples/ocr-correction-viklofg-sweocr
echo "" | sparv setup
sparv run
ls -R
Expand All @@ -145,95 +153,3 @@ jobs:
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}

build:
name: ubuntu / 3.9 / build package
# only run on push to main and on release
if: success() && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
runs-on: ubuntu-latest
steps:
#----------------------------------------------
# check-out repo and set-up python
#----------------------------------------------
- name: Check out repository
uses: actions/checkout@v4

#----------------------------------------------
# ----- setup python -----
#----------------------------------------------
- name: Set up the environment
uses: pdm-project/setup-pdm@v4
id: setup-python
with:
python-version: ${{ env.MINIMUM_PYTHON_VERSION }}

#----------------------------------------------
# ----- build distribution -----
#----------------------------------------------
- name: Build distribution
run: make build

#----------------------------------------------
# ----- upload artifacts -----
#----------------------------------------------
- uses: actions/upload-artifact@v4
with:
name: pypi_files
path: dist

test-build:
needs: [build]

strategy:
fail-fast: false
matrix:
os: [ubuntu]
name: ${{ matrix.os }} / 3.9 / test built package

runs-on: ${{ matrix.os }}-latest
steps:
- uses: actions/checkout@v4

- name: set up python
uses: actions/setup-python@v5
with:
python-version: ${{ env.MINIMUM_PYTHON_VERSION }}

- name: get dist artifacts
uses: actions/download-artifact@v4
with:
name: pypi_files
path: dist

- run: rm -r src/ocr_correction
- run: pip install typing-extensions
- run: pip install -r tests/requirements-testing.lock
- run: pip install sparv-ocr-correction-plugin --no-index --no-deps --find-links dist --force-reinstall
- run: pytest

publish:
needs:
- test-check
- test-build
if: success() && startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
environment: release
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python ${{ env.MINIMUM_PYTHON_VERSION }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.MINIMUM_PYTHON_VERSION }}
- name: get dist artifacts
uses: actions/download-artifact@v4
with:
name: pypi_files
path: dist

- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
34 changes: 34 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-yaml
stages: [commit]
- id: check-json
stages: [commit]
- id: check-toml
stages: [commit]
- id: check-merge-conflict
stages: [commit]
- id: check-case-conflict
stages: [commit]
- id: detect-private-key
stages: [commit]
# - id: end-of-file-fixer
- id: check-added-large-files
stages: [commit]
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.3.2
hooks:
# Run the linter.
- id: ruff
# Run the formatter.
- id: ruff-format
- repo: https://github.com/crate-ci/committed
rev: v1.0.20
hooks:
- id: committed
stages: [commit-msg]
Loading

0 comments on commit 48b7c33

Please sign in to comment.