Skip to content

Commit

Permalink
Merge pull request #9 from statisticsnorway/update_template
Browse files Browse the repository at this point in the history
Update template
  • Loading branch information
Edvard Garmannslund authored Feb 14, 2024
2 parents d9a71f5 + 1054eef commit 51b260d
Show file tree
Hide file tree
Showing 13 changed files with 545 additions and 865 deletions.
4 changes: 2 additions & 2 deletions .cruft.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"template": "https://github.com/statisticsnorway/ssb-pypitemplate.git",
"commit": "6f05a1849ca259b5b19e9c213b41d42cab872644",
"checkout": "2023.11.15",
"commit": "e81154758223bbeb62e2117de27029295c13e126",
"checkout": null,
"context": {
"cookiecutter": {
"project_name": "ssb-konjunk",
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,21 @@ jobs:
poetry --version
- name: Set up Python
uses: actions/setup-python@v4.7.1
uses: actions/setup-python@v5.0.0
with:
python-version: "3.11"
cache: "poetry"

- name: Install dependencies
run: |
poetry install --no-root
poetry install
- name: Build doc with Sphinx
run: |
poetry run sphinx-build -W docs docs/_build
poetry run sphinx-build docs docs/_build
- name: Upload artifact
uses: actions/upload-pages-artifact@v2
uses: actions/upload-pages-artifact@v3
with:
path: "docs/_build"

Expand All @@ -60,8 +60,8 @@ jobs:
needs: build
steps:
- name: Setup Pages
uses: actions/configure-pages@v3
uses: actions/configure-pages@v4

- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
uses: actions/deploy-pages@v4
10 changes: 5 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
fetch-depth: 2

- name: Set up Python
uses: actions/setup-python@v4.7.1
uses: actions/setup-python@v5.0.0
with:
python-version: "3.11"

Expand Down Expand Up @@ -49,7 +49,7 @@ jobs:
bash -o pipefail -c "poetry version | cut -f 2 -d' '"
- name: Bump version for developmental release
if: "! steps.check-version.outputs.tag"
if: (!steps.check-version.outputs.tag)
run: |
poetry version patch &&
version=$(poetry version | awk '{ print $2 }') &&
Expand All @@ -61,11 +61,11 @@ jobs:
- name: Publish package on PyPI
if: steps.check-version.outputs.tag
uses: pypa/[email protected].10
uses: pypa/[email protected].11

- name: Publish package on TestPyPI
if: "! steps.check-version.outputs.tag"
uses: pypa/[email protected].10
if: (!steps.check-version.outputs.tag)
uses: pypa/[email protected].11
with:
repository-url: https://test.pypi.org/legacy/

Expand Down
23 changes: 13 additions & 10 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v4.7.1
uses: actions/setup-python@v5.0.0
with:
python-version: ${{ matrix.python }}

Expand Down Expand Up @@ -84,7 +84,7 @@ jobs:
subprocess.run(cmd, shell=True)
- name: Restore pre-commit cache
uses: actions/cache@v3
uses: actions/cache@v4
if: matrix.session == 'pre-commit'
with:
path: ~/.cache/pre-commit
Expand All @@ -98,14 +98,14 @@ jobs:
- name: Upload coverage data
if: always() && matrix.session == 'tests'
uses: "actions/upload-artifact@v3"
uses: "actions/upload-artifact@v4"
with:
name: coverage-data
name: coverage-data-${{ matrix.os }}-${{ matrix.python }}
path: ".coverage.*"

- name: Upload documentation
if: matrix.session == 'docs-build'
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: docs
path: docs/_build
Expand All @@ -120,7 +120,7 @@ jobs:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis

- name: Set up Python
uses: actions/setup-python@v4.7.1
uses: actions/setup-python@v5.0.0
with:
python-version: "3.11"

Expand All @@ -141,9 +141,10 @@ jobs:
nox --version
- name: Download coverage data
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: coverage-data
pattern: coverage-data-*
merge-multiple: true

- name: Combine coverage data and display human readable report
run: |
Expand All @@ -156,12 +157,14 @@ jobs:
# Need to fix coverage source paths for SonarCloud scanning in GitHub actions.
# Replace root path with /github/workspace (mounted in docker container).
- name: Override coverage source paths for SonarCloud
run: sed -i "s/<source>\/home\/runner\/work\/ssb-konjunk\/ssb-konjunk/<source>\/github\/workspace/g" coverage.xml
run: |
sed -i "s/<source><\/source>/<source>\/github\/workspace<\/source>/g" coverage.xml
sed -i "s/<source>tests/<source>\/github\/workspace\/tests/g" coverage.xml
- name: SonarCloud Scan
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
# No need to run SonarCloud analysis if dependabot update or token not defined
if: env.SONAR_TOKEN != '' && (github.actor != 'dependabot[bot]')
uses: SonarSource/sonarcloud-github-action@v2.0.2
uses: SonarSource/sonarcloud-github-action@v2.1.1
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -204,3 +204,18 @@ rsconnect/

# ignore poetry in .config
.poetry/**
/.python-version
/.pytype/
/docs/_build/

# Visual Studio Code
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/*.code-snippets
# Local History for Visual Studio Code
.history/
# Built Visual Studio Code Extensions
*.vsix
63 changes: 43 additions & 20 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ Here is a list of important resources for contributors:
- [Issue Tracker]
- [Code of Conduct]

[mit license]: https://opensource.org/licenses/MIT
[source code]: https://github.com/statisticsnorway/ssb-konjunk
[documentation]: https://ssb-konjunk.readthedocs.io/
[issue tracker]: https://github.com/statisticsnorway/ssb-konjunk/issues

## How to report a bug

Report bugs on the [Issue Tracker].
Expand Down Expand Up @@ -43,50 +38,69 @@ You need Python 3.9+ and the following tools:
- [Nox]
- [nox-poetry]

Install the package with development requirements:
Install [pipx]:

```console
$ poetry install
python -m pip install --user pipx
python -m pipx ensurepath
```

You can now run an interactive Python session,
or the command-line interface:
Install [Poetry]:

```console
$ poetry run python
$ poetry run ssb-konjunk
pipx install poetry
```

[poetry]: https://python-poetry.org/
[nox]: https://nox.thea.codes/
[nox-poetry]: https://nox-poetry.readthedocs.io/
Install [Nox] and [nox-poetry]:

```console
pipx install nox
pipx inject nox nox-poetry
```

Install the pre-commit hooks

```console
nox --session=pre-commit -- install
```

Install the package with development requirements:

```console
poetry install
```

You can now run an interactive Python session, or your app:

```console
poetry run python
poetry run ssb-konjunk
```

## How to test the project

Run the full test suite:

```console
$ nox
nox
```

List the available Nox sessions:

```console
$ nox --list-sessions
nox --list-sessions
```

You can also run a specific Nox session.
For example, invoke the unit test suite like this:

```console
$ nox --session=tests
nox --session=tests
```

Unit tests are located in the _tests_ directory,
and are written using the [pytest] testing framework.

[pytest]: https://pytest.readthedocs.io/

## How to submit changes

Open a [pull request] to submit changes to this project.
Expand All @@ -102,12 +116,21 @@ Feel free to submit early, though—we can always iterate on this.
To run linting and code formatting checks before committing your change, you can install pre-commit as a Git hook by running the following command:

```console
$ nox --session=pre-commit -- install
nox --session=pre-commit -- install
```

It is recommended to open an issue before starting work on anything.
This will allow a chance to talk it over with the owners and validate your approach.

[mit license]: https://opensource.org/licenses/MIT
[source code]: https://github.com/statisticsnorway/ssb-konjunk
[documentation]: https://statisticsnorway.github.io/ssb-konjunk
[issue tracker]: https://github.com/statisticsnorway/ssb-konjunk/issues
[pipx]: https://pipx.pypa.io/
[poetry]: https://python-poetry.org/
[nox]: https://nox.thea.codes/
[nox-poetry]: https://nox-poetry.readthedocs.io/
[pytest]: https://pytest.readthedocs.io/
[pull request]: https://github.com/statisticsnorway/ssb-konjunk/pulls

<!-- github-only -->
Expand Down
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Sphinx configuration."""

# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
Expand Down
1 change: 1 addition & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Nox sessions."""

import os
import shlex
import shutil
Expand Down
Loading

0 comments on commit 51b260d

Please sign in to comment.