-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from spraakbanken/setup-ci
setup ci
- Loading branch information
Showing
23 changed files
with
6,863 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# https://editorconfig.org/ | ||
|
||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
insert_final_newline = true | ||
|
||
[*.py] | ||
indent_style = space | ||
indent_size = 4 | ||
max_line_length = 120 | ||
trim_trailing_whitespace = true | ||
|
||
[*.yaml] | ||
indent_style = space | ||
indent_size = 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Github config and workflows | ||
|
||
In this folder there is configuration for codecoverage, dependabot and ci workflows. | ||
|
||
This folder can be merged using a `--allow-unrelated-histories` merge strategy from <https://github.com/spraakbanken/python-pdm-ci-conf> which provides a reasonably sensible base for writing your own ci on. By using this strategy the history of the CI repo is included in your repo, and future updates to the CI can be merged later. | ||
|
||
The workflows in this folder requires a root Makefile with a couple of targets defined. | ||
As base can the Makefile in <https://github.com/spraakbanken/python-pdm-make-conf> be used. | ||
|
||
## Publish | ||
|
||
The `publish`-step in [test.yml](./workflows/test.yml) is configured to use the GitHub environment `release`, create that or change to your preferred environment. | ||
To publish to PyPI you must also configure your Pypi-project settings to use Trusted Publisher Management, by setting repo, workflow and environment on PyPI. | ||
|
||
To perform this merge run: | ||
|
||
```shell | ||
git remote add ci [email protected]:spraakbanken/python-pdm-ci-conf.git | ||
git fetch ci | ||
git merge --allow-unrelated-histories ci/main | ||
``` | ||
|
||
or add the remote as `git remote add ci https://github.com/spraakbanken/python-pdm-ci-conf.git` | ||
|
||
To later merge updates to this repo, just run: | ||
|
||
```shell | ||
git fetch ci | ||
get merge ci/main | ||
``` | ||
|
||
This setup is inspired by <https://github.com/jonhoo/rust-ci-conf>. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# ref: https://docs.codecov.com/docs/codecovyml-reference | ||
coverage: | ||
# Hold ourselves to a high bar | ||
range: 85..100 | ||
round: down | ||
precision: 1 | ||
status: | ||
# ref: https://docs.codecov.com/docs/commit-status | ||
project: | ||
default: | ||
# Avoid false negatives | ||
threshold: 1% | ||
|
||
# Test files aren't important for coverage | ||
ignore: | ||
- "tests" | ||
|
||
# Make comments less noisy | ||
comment: | ||
layout: "files" | ||
require_changes: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# To get started with Dependabot version updates, you'll need to specify which | ||
# package ecosystems to update and where the package manifests are located. | ||
# Please see the documentation for all configuration options: | ||
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates | ||
|
||
version: 2 | ||
updates: | ||
# Maintain dependencies for GitHub Actions | ||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "weekly" | ||
- package-ecosystem: "pip" # See documentation for possible values | ||
directory: "/" # Location of package manifests | ||
schedule: | ||
interval: "daily" | ||
ignore: | ||
- dependency-name: "*" | ||
# patch and minor updates don't matter for libraries as consumers of this library build | ||
# with their own lockfile, rather than the version specified in this library's lockfile | ||
# remove this ignore rule if your package has binaries to ensure that the binaries are | ||
# built with the exact set of dependencies and those are up to date. | ||
update-types: | ||
- "version-update:semver-patch" | ||
- "version-update:semver-minor" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
name: check | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
merge_group: | ||
|
||
permissions: | ||
contents: read | ||
|
||
env: | ||
MINIMUM_PYTHON_VERSION: "3.8" | ||
|
||
# If new code is pushed to a PR branch, then cancel in progress workflows for that PR. Ensures that | ||
# we don't waste CI time, and returns results quicker https://github.com/jonhoo/rust-ci-conf/pull/5 | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
fmt: | ||
runs-on: ubuntu-latest | ||
name: ubuntu / 3.8 / fmt | ||
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 | ||
with: | ||
python-version: ${{ env.MINIMUM_PYTHON_VERSION }} | ||
|
||
- name: Load cached venv | ||
id: cached-venv | ||
uses: actions/cache@v4 | ||
with: | ||
path: .venv | ||
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/pyproject.toml') }}-${{ hashFiles('.github/workflows/check.yml') }} | ||
|
||
- name: Install dependencies | ||
if: steps.cached-venv.outputs.cache-hit != 'true' | ||
run: make install-dev | ||
|
||
- name: check formatting | ||
run: make check-fmt | ||
lint: | ||
runs-on: ubuntu-latest | ||
name: ubuntu / 3.8 / 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 | ||
with: | ||
python-version: ${{ env.MINIMUM_PYTHON_VERSION }} | ||
- name: Load cached venv | ||
id: cached-venv | ||
uses: actions/cache@v4 | ||
with: | ||
path: .venv | ||
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/pyproject.toml') }}-${{ hashFiles('.github/workflows/check.yml') }} | ||
- name: Install dependencies | ||
if: steps.cached-venv.outputs.cache-hit != 'true' | ||
run: make install-dev | ||
- name: lint code | ||
run: make lint | ||
type-check: | ||
runs-on: ubuntu-latest | ||
name: ubuntu / 3.8 / 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 | ||
with: | ||
python-version: ${{ env.MINIMUM_PYTHON_VERSION }} | ||
- name: Load cached venv | ||
id: cached-venv | ||
uses: actions/cache@v4 | ||
with: | ||
path: .venv | ||
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/pyproject.toml') }}-${{ hashFiles('.github/workflows/check.yml') }} | ||
- name: Install dependencies | ||
if: steps.cached-venv.outputs.cache-hit != 'true' | ||
run: make install-dev | ||
- name: type-check code | ||
run: make type-check | ||
|
||
# https://github.com/marketplace/actions/alls-green#why used for branch protection checks | ||
check-check: | ||
if: always() | ||
needs: | ||
- fmt | ||
- lint | ||
- type-check | ||
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: upload-coverage |
136 changes: 136 additions & 0 deletions
136
.github/workflows/release-sentence-sentiment-kb-sent.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
name: release-sentence-sentiment-kb-sent | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
tags: | ||
- 'sentence-sentiment-kb-sent-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.8" | ||
|
||
jobs: | ||
build: | ||
# This action builds distribution files for upload to PyPI | ||
|
||
name: ubuntu / 3.8 / 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 sparv-sbx-sentence-sentiment-kb-sent && make build | ||
|
||
#---------------------------------------------- | ||
# ----- upload artifacts ----- | ||
#---------------------------------------------- | ||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: pypi_files | ||
path: sparv-sbx-sentence-sentiment-kb-sent/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.8 / 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 sparv-sbx-sentence-sentiment-kb-sent/src | ||
- run: pip install typing-extensions | ||
- run: pip install -r sparv-sbx-sentence-sentiment-kb-sent/tests/requirements-testing.lock | ||
- run: pip install sparv-sbx-sentence-sentiment-kb-sent --no-index --no-deps --find-links dist --force-reinstall | ||
- run: pytest | ||
|
||
# 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/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 |
Oops, something went wrong.