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

Modernize #364

Merged
merged 8 commits into from
May 8, 2024
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
14 changes: 4 additions & 10 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
[report]
skip_covered = True
show_missing = True
precision = 2
exclude_lines =
def __repr__
continue
raise NotImplementedError
if __name__ == .__main__.:
log
print
# Don't complain if non-runnable code isn't run:
if __name__ == .__main__.

[run]
omit =
src/forklift/__main__.py
src/forklift/__main__.py
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
root = true

[*.py]
indent_size = 4

[*]
indent_style = space
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
1 change: 1 addition & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
51699f13b5e9044cfde4b43811900e8557f1db7f
21 changes: 21 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
version: 2
updates:
- package-ecosystem: pip
directory: /
schedule:
interval: monthly
groups:
safe-dependencies:
update-types: ["minor", "patch"]
major-dependencies:
update-types: ["major"]
commit-message:
prefix: deps
prefix-development: deps(dev)
- package-ecosystem: github-actions
directory: /
schedule:
interval: monthly
groups:
ci-dependencies:
dependency-type: "production"
44 changes: 44 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Pull Request Events

on:
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true

permissions: {}

jobs:
test-unit:
name: Unit Tests
runs-on: ubuntu-latest

steps:
- name: ⬇️ Set up code
uses: actions/checkout@v4
with:
show-progress: false

- name: 🐍 Set up Python
uses: actions/setup-python@v5
with:
cache: pip
cache-dependency-path: setup.py

- name: 📥 Install arcgis dependencies
run: |
sudo apt-get update
sudo apt-get install -y libkrb5-dev

- name: 🏗 Install module
run: pip install .[tests]

- name: 🧶 Lint
run: ruff check --output-format=github .

- name: ⬆️ Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./cov.xml
66 changes: 66 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Push Events

on:
push:
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
release-please:
name: Create release
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
outputs:
release_created: ${{ steps.release-please.outputs.release_created }}

steps:
- name: 🚀 Create Release
id: release-please
uses: agrc/release-composite-action@v1
with:
release-type: python
prerelease: ${{ github.ref_name == 'dev' }}
repo-token: ${{ secrets.GITHUB_TOKEN }}
github-app-id: ${{ secrets.UGRC_RELEASE_BOT_APP_ID }}
github-app-key: ${{ secrets.UGRC_RELEASE_BOT_APP_KEY }}
github-app-name: ${{ secrets.UGRC_RELEASE_BOT_NAME }}
github-app-email: ${{ secrets.UGRC_RELEASE_BOT_EMAIL }}

upload-coverage:
name: Upload coverage
runs-on: ubuntu-latest
needs: release-please
if: needs.release-please.outputs.release_created

steps:
- name: ⬇️ Set up code
uses: actions/checkout@v4
with:
show-progress: false

- name: 🐍 Set up Python
uses: actions/setup-python@v5
with:
cache: pip
cache-dependency-path: setup.py

- name: 🏗 Install module
run: pip install .[tests]

- name: ⚙️ Add config file
run: cp config.sample.json config.json

- name: 🧪 Run tests
run: pytest

- name: ⬆️ Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./cov.xml
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pip-log.txt
nosetests.xml
htmlcov
.noseids
cov.xml

.DS_Store
*~
Expand Down
14 changes: 0 additions & 14 deletions .pylintrc

This file was deleted.

1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.9
9 changes: 0 additions & 9 deletions .style.yapf

This file was deleted.

21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) UGRC

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
24 changes: 7 additions & 17 deletions readme.md → README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ From within the [ArcGIS Pro conda environment](http://pro.arcgis.com/en/pro-app/
1. Create a conda environment for forklift `conda create --name forklift python=3.9`.
1. Activate the conda environment `activate forklift`.
1. `conda install arcpy -c esri`
1. Chckout forklift repository: `git clone https://github.com/agrc/forklift.git`
1. Checkout forklift repository: `git clone https://github.com/agrc/forklift.git`
1. `pip install .\` from the directory containing `setup.py`.
1. Install the python dependencies for your pallets.
1. `forklift config init`
Expand Down Expand Up @@ -190,29 +190,19 @@ If you do need to recreate the forklift environment from scratch, follow these s
- create new env
- `conda create --name forklift --clone arcgispro-py3`
- `activate forklift`
- install deps
- conda or pip install everything in the `setup.py` `install_requires`
- optionally install forklift
- `cd forklift`
- `pip install .\ -U`
- install forklift and deps
- `pip install -e ".[tests]"`
- run forklift
- for the installed version execute `forklift -h`
- for the source version, from the `**/src**` directory, execute `python -m forklift -h` for usage
- `forklift -h`

### Tests

#### On first run
Tests should show up in VSCode's text explorer.

- install deps
- `pip install -e ".[tests]"`
- run tests
- `python setup.py develop`
- `pytest -p no:faulthandler`
To run them from the command line:

`-p no:faulthandler` is to [prevent pytest from printing _tons_ of errors](https://stackoverflow.com/a/65826036/8049053).
- `pytest`

_Tests that depend on a local SDE database (see `tests/data/UPDATE_TESTS.bak`) will automatically be skipped if it is not found on your system._

To run a specific test or suite: `pytest -k <test/suite name>`

If you have pip installed forklift into your current environment, you may need to uninstall it to get tests to see recent updates to the source code.
12 changes: 12 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[tool.ruff]
line-length = 120
extend-exclude = ["*/PalletWithSyntaxErrors.py"]
[tool.ruff.lint]
ignore = ["E501"]
[tool.pytest.ini_options]
minversion = "6.0"
testpaths = ["tests", "src"]
norecursedirs = [".env", "data", ".github", ".vscode"]
console_output_style = "count"
addopts = "--cov-branch --cov=forklift --cov-report term --cov-report xml:cov.xml --instafail -p no:faulthandler"
# `-p no:faulthandler` is to [prevent pytest from printing _tons_ of errors](https://stackoverflow.com/a/65826036/8049053).
9 changes: 0 additions & 9 deletions pytest.ini

This file was deleted.

7 changes: 4 additions & 3 deletions samples/ChangeDetectionPallet.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#!/usr/bin/env python
# * coding: utf8 *
'''
"""
ChangeDetectionPallet.py
A module containing an sample of a pallet that uses change detection.j

Note: In order for this pallet to use change detection, the `changeDetectionTables` config prop needs to
have `UPDATE_TESTS.sde\\ChangeDetection` in it's array.
'''
"""

from os.path import join

import arcpy
Expand All @@ -15,4 +16,4 @@

class ChangeDetectionPallet(Pallet):
def build(self, configuration):
self.add_crate(('ChangeDetectionPallet', join(self.garage, 'UPDATE_TESTS.sde'), arcpy.env.scratchGDB))
self.add_crate(("ChangeDetectionPallet", join(self.garage, "UPDATE_TESTS.sde"), arcpy.env.scratchGDB))
Loading
Loading