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

Lint and format with pre-commit #534

Merged
merged 6 commits into from
Jun 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
70 changes: 0 additions & 70 deletions .circleci/config.yml

This file was deleted.

26 changes: 0 additions & 26 deletions .flake8

This file was deleted.

74 changes: 74 additions & 0 deletions .github/workflows/test-and-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: "Test and (if tag) build"

on:
push:
branches:
- "*"
tags:
- "v[0-9]+.[0-9]+.[0-9]+*"
pull_request:


# Default to bash in login mode; key to activating conda environment
# https://github.com/mamba-org/provision-with-micromamba#IMPORTANT
defaults:
run:
shell: "bash -l {0}"


jobs:
test:
runs-on: "ubuntu-latest"
steps:
- name: "Check out repository"
uses: "actions/checkout@v3"

- name: "Apt install libgl1-mesa-glx"
run: |
# Install libgl1-mesa-glx. Import errors occur otherwise.
# See: https://app.circleci.com/jobs/github/nsidc/qgreenland/72/parallel-runs/0/steps/0-102
sudo apt-get update
sudo apt-get install -y libgl1-mesa-glx

# Rename lock file; mamba expects files ending in `-lock.yml` to have a different format :(
# https://github.com/mamba-org/mamba/issues/1209#issuecomment-1447546266
- name: "HACK: Rename lockfile"
run: "mv environment-lock.yml environment-ci.yml"

- name: "Install Conda environment"
uses: "mamba-org/setup-micromamba@v1.4.1"
with:
environment-file: "environment-ci.yml"
cache-environment: true

- name: "Run tests"
run: "inv test.ci"
env:
# QGIS complains when setting up an QgsApplicatoin if `QT_QPA_PLATFORM` is not
# set to `offscreen`:
# qt.qpa.xcb: could not connect to display
# qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even
# though it was found.
# This application failed to start because no Qt
# platform plugin could be initialized. Reinstalling the application
# may fix this problem.
#
# Available platform plugins are: eglfs, minimal, minimalegl,
# offscreen, vnc, webgl, xcb.
#
# Fatal Python error: Aborted
QT_QPA_PLATFORM: offscreen


build:
runs-on: "ubuntu-latest"
needs: ["test"]
if: "github.ref_type == 'tag'"
steps:
- name: "Trigger Jenkins to build QGreenland Core"
run: |
JOB_NAME="qgreenland_C3_Production_Build_QGreenland_Package"
JOB_URL="${{ secrets.JENKINS_URL }}/job/${JOB_NAME}"
JOB_BUILD_URL="${JOB_URL}/buildWithParameters?ref=${{ github.ref_name }}&delay=5sec"

wget "$JOB_BUILD_URL"
44 changes: 44 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
default_language_version:
python: "python3.10"


repos:

- repo: "https://github.com/pre-commit/pre-commit-hooks"
rev: "v4.4.0"
hooks:
- id: "check-added-large-files"
- id: "check-vcs-permalinks"
- id: "end-of-file-fixer"

- repo: "https://github.com/charliermarsh/ruff-pre-commit"
rev: "v0.0.269"
hooks:
- id: "ruff"
# NOTE: "--exit-non-zero-on-fix" is important for CI to function
# correctly!
args: ["--fix", "--exit-non-zero-on-fix"]

- repo: "https://github.com/psf/black"
rev: "23.3.0"
hooks:
- id: "black"

- repo: "https://github.com/jendrikseipp/vulture"
rev: "v2.7"
hooks:
- id: "vulture"

# Commented because it requires Docker, which is not available in all CI
# runners. Works on GitHub actions but not CircleCI.
# - repo: "https://github.com/koalaman/shellcheck-precommit"
# rev: "v0.9.0"
# hooks:
# - id: "shellcheck"
# # args: ["--severity=warning"] # Optionally only show errors and warnings
#

- repo: "https://github.com/shellcheck-py/shellcheck-py"
rev: "v0.9.0.5"
hooks:
- id: "shellcheck"
1 change: 0 additions & 1 deletion doc/_notes/20200115_notes.org
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,3 @@
- Place names
- DEMs
- Contour lines

2 changes: 1 addition & 1 deletion doc/contributor-how-to/how-to-dev-plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ Navigate to **Plugins -> Plugin Reloader -> Reload Plugin: qgreenland-plugin**.
You should receive a message notifying you that the plugin has been reloaded.

After reloading the plugin, you are all set to begin using QGreenland Custom. Reference the user guide,
**How to install and use QGreenland Custom**, to get started.
**How to install and use QGreenland Custom**, to get started.
25 changes: 25 additions & 0 deletions doc/contributor-how-to/use-our-tooling.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# How to use QGreenland development tooling

## Linting and formatting

This project uses [pre-commit](https://pre-commit.com/) for linting and code formatting.
This dependency is already part of the QGreenland Conda environment! To set it up,
simply:

```
pre-commit install
```

This will configure Git hooks which will trigger when you make a commit.


## Testing and other stuff

We use [invoke](https://www.pyinvoke.org/) for other miscellaneous tasks, like:

* Environment locking (`inv env.lock`)
* Interactive docs building (`inv docs.watch`)
* Typechecking (`inv test.typecheck`)
* ... and much, much more!

Use `inv --list` to view a list of available tasks.
2 changes: 1 addition & 1 deletion doc/reference/glossary/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ Glossary
:glob:

./user-glossary.md
./contributor-glossary.md
./contributor-glossary.md
2 changes: 1 addition & 1 deletion doc/reference/glossary/user-glossary.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@ targeted use. Modules include:
value.

- **Vector**: A layer type consisting of either points, lines, or polygons, where each point,
line, or polygon has a unique set of attribute values.
line, or polygon has a unique set of attribute values.
1 change: 0 additions & 1 deletion doc/tutorials/analyze-ice-sheet-volume.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,3 @@ sheet thickness data included in the QGreenland core package to calculate the
volume of the Greenland ice sheet. Having accomplished this, the user is now
ready to explore other geospatial processing tools included in the **Processing
Toolbox** to further analyze other QGreenland data.

Loading