Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setup ci #5

Merged
merged 60 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
fd39052
initial commit
kod-kristoff Feb 6, 2024
cd66ecf
refactor: rename to check-check
kod-kristoff Feb 6, 2024
1c2fa68
feat: add minimal and doctests jobs
kod-kristoff Feb 6, 2024
ea7a260
Bump actions/cache from 3 to 4
dependabot[bot] Feb 6, 2024
a37c337
initial commit
kod-kristoff Feb 6, 2024
85a148e
fix: adjust names
kod-kristoff Feb 6, 2024
c54965f
Merge pull request #1 from spraakbanken/dependabot/github_actions/act…
kod-kristoff Feb 6, 2024
d2bb666
fix: make code more mergeable
kod-kristoff Feb 6, 2024
9aa9db8
ci: fix so that nightly uses 3.13-dev
kod-kristoff Feb 6, 2024
ae5d28b
ci: fix typo
kod-kristoff Feb 6, 2024
90f2b02
ci: add concurreny to test
kod-kristoff Feb 6, 2024
7638105
build: use pdm export
kod-kristoff Feb 6, 2024
c364ae8
ci(scheduled): install pdm separate
kod-kristoff Feb 6, 2024
719ee8b
ci: add check-for-updates
kod-kristoff Feb 6, 2024
52bd87f
ci(test): move codecov upload
kod-kristoff Feb 8, 2024
54a4b05
chore(test): add cov_report=xml
kod-kristoff Feb 8, 2024
a537160
ci(scheduled): bump update-deps-action
kod-kristoff Feb 8, 2024
25ad298
test: rename lock file
kod-kristoff Feb 23, 2024
78e5113
docs: add reason
kod-kristoff Feb 23, 2024
6933de2
docs: add info about publish
kod-kristoff Feb 23, 2024
d1446b1
ci: remove check-for-updates
kod-kristoff Feb 23, 2024
92a3cbc
ci: use right lockfile
kod-kristoff Feb 23, 2024
48dfd53
ci: also run test on tags v
kod-kristoff Mar 4, 2024
878d0ed
ci: split test in release and test
kod-kristoff Mar 12, 2024
7313469
ci: set 3.8 as minimum_python_version
kod-kristoff Mar 12, 2024
8310467
ci: also checkout submodules as default
kod-kristoff Mar 12, 2024
5690fac
build: add install target
kod-kristoff Mar 12, 2024
e2b800f
build: add lint-fix target
kod-kristoff Mar 12, 2024
74c08e9
ci: change new on release workflow
kod-kristoff Mar 12, 2024
b460dc4
ci: fix typo
kod-kristoff Mar 12, 2024
d5eb409
chore: switch to bump-my-version
kod-kristoff Mar 13, 2024
6556cf9
chore: fix bump-my-version command
kod-kristoff Mar 13, 2024
5c60057
ci: don't run test workflows on tags
kod-kristoff Mar 13, 2024
02a60fc
ci(check): fix typo
kod-kristoff Mar 14, 2024
9f8af83
ci: use hashes from pdm.lock also
kod-kristoff Apr 16, 2024
b1330dc
chore: add changelog update
kod-kristoff Apr 22, 2024
424e74b
chore: add snapshot-update target
kod-kristoff Apr 22, 2024
c1de824
chore(make): dont use backticks
kod-kristoff Apr 25, 2024
18c3539
chore(make): add lock target
kod-kristoff May 6, 2024
aa52afe
chore: mark CHANGELOG.md as phony
kod-kristoff May 15, 2024
3801a39
chore(make): add project line
kod-kristoff May 30, 2024
d4b729b
chore: generate test lock file w/o hashes
kod-kristoff Jun 13, 2024
0376c9f
style: after fmt
kod-kristoff Aug 15, 2024
5bebf8b
chore: project setup
kod-kristoff Aug 15, 2024
be80759
chore: add pre-commit config
kod-kristoff Aug 15, 2024
9d21d3b
chore: add ruff config
kod-kristoff Aug 15, 2024
984423b
chore: add cog config
kod-kristoff Aug 15, 2024
1c99d2d
Merge remote-tracking branch 'make/main' into setup-ci
kod-kristoff Aug 15, 2024
3781891
chore: configure Makefile
kod-kristoff Aug 15, 2024
ffd73a6
Merge remote-tracking branch 'ci/main' into setup-ci
kod-kristoff Aug 15, 2024
cadc639
ci: rename release workflow
kod-kristoff Aug 16, 2024
6d811ce
docs: add project README
kod-kristoff Aug 16, 2024
70c8236
chore: remove license from [project]
kod-kristoff Aug 16, 2024
d660636
chore(dev-deps): add bump-my-version
kod-kristoff Aug 16, 2024
53e3a16
ci: adjust release workflow
kod-kristoff Aug 16, 2024
1fae863
chore: add constants.py
kod-kristoff Aug 16, 2024
21c9d4b
test: add test_version
kod-kristoff Aug 16, 2024
02e6c51
chore: add project Makefile
kod-kristoff Aug 16, 2024
29b5c7c
test: add tests/requirements-testing.lock
kod-kristoff Aug 16, 2024
0e7d36a
ci: allow errors for test/doctests
kod-kristoff Aug 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/DOCS.md
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>.
21 changes: 21 additions & 0 deletions .github/codecov.yml
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
25 changes: 25 additions & 0 deletions .github/dependabot.yml
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"
111 changes: 111 additions & 0 deletions .github/workflows/check.yml
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('**/pdm.lock') }}-${{ 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('**/pdm.lock') }}-${{ 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('**/pdm.lock') }}-${{ 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
138 changes: 138 additions & 0 deletions .github/workflows/release-sent-emoclass-kb-emoclass.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
name: release-sent-emoclass-kb-emoclass

on:
push:
branches:
- main
tags:
- "sent-emoclass-kb-emoclass-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-emotional-classification-kb-emoclass && make build

#----------------------------------------------
# ----- upload artifacts -----
#----------------------------------------------
- uses: actions/upload-artifact@v4
with:
name: pypi_files
path: sparv-sbx-sentence-emotional-classification-kb-emoclass/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
- macos
- windows

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-emotional-classification-kb-emoclass/src
- run: pip install typing-extensions
- run: pip install -r sparv-sbx-sentence-emotional-classification-kb-emoclass/tests/requirements-testing.lock
- run: pip install sparv-sbx-sentence-emotional-classification-kb-emoclass --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/sent-emoclass-kb-emoclass-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
Loading
Loading