Skip to content

Commit

Permalink
Reset repo for new pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
b-j-mills committed Jan 22, 2025
1 parent d166855 commit b833613
Show file tree
Hide file tree
Showing 37 changed files with 1,197 additions and 413 deletions.
1 change: 1 addition & 0 deletions .coveragerc → .config/coveragerc
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ omit =
*/site-packages/*
*/tests/*
*__init__*
*/_version.py

exclude_lines =
if __name__ == '__main__':
33 changes: 33 additions & 0 deletions .config/pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
default_language_version:
python: python3.12
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
exclude: test_scraper_.*\.json
- id: check-ast
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.1
hooks:
# Run the linter.
- id: ruff
args: [--config, .config/ruff.toml, --fix]
# Run the formatter.
- id: ruff-format
args: [--config, .config/ruff.toml]
- repo: https://github.com/astral-sh/uv-pre-commit
rev: 0.2.37
hooks:
# Run the pip compile
- id: pip-compile
name: pip-compile requirements.txt
files: pyproject.toml
args: [ pyproject.toml, --resolver=backtracking, --upgrade, -q,
-o, requirements.txt ]
- id: pip-compile
name: pip-compile requirements-test.txt
files: pyproject.toml
args: [ pyproject.toml, --resolver=backtracking, --upgrade, -q,
--extra, test, -c, requirements.txt, -o, requirements-test.txt ]
4 changes: 4 additions & 0 deletions .config/pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[pytest]
pythonpath = ../src
addopts = "--color=yes"
log_cli = 1
14 changes: 14 additions & 0 deletions .config/ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
line-length = 79
exclude = ["_version.py"]

[lint]
# List of rules: https://docs.astral.sh/ruff/rules/
select = [
"E", # pycodestyle - default
"F", # pyflakes - default
"I" # isort
]

[lint.isort]
known-local-folder = ["hdx.scraper.acled"]
known-third-party = ["hdx.api", "hdx.location", "hdx.data", "hdx.database", "hdx.facades", "hdx.scraper", "hdx.utilities"]
51 changes: 0 additions & 51 deletions .github/workflows/build.yml

This file was deleted.

53 changes: 53 additions & 0 deletions .github/workflows/run-python-script.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# This workflow will install Python dependencies and run the script

name: Run script

on:
workflow_dispatch: # add run button in github
schedule:
- cron: "32 10 * * *"

jobs:
run:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Python 3.x
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
pip install .
- name: Run script
env:
HDX_SITE: ${{ vars.HDX_SITE }}
HDX_KEY: ${{ secrets.HDX_BOT_SCRAPERS_API_TOKEN }}
PREPREFIX: ${{ secrets.HDX_PIPELINE_PREPREFIX }}
USER_AGENT: ${{ vars.USER_AGENT }}
EXTRA_PARAMS: ${{ vars.EXTRA_PARAMS }}
run: |
python -m hdx.scraper.acled
- name: Send mail
if: failure()
uses: dawidd6/action-send-mail@v3
with:
server_address: ${{secrets.HDX_PIPELINE_EMAIL_SERVER}}
server_port: ${{secrets.HDX_PIPELINE_EMAIL_PORT}}
username: ${{secrets.HDX_PIPELINE_EMAIL_USERNAME}}
password: ${{secrets.HDX_PIPELINE_EMAIL_PASSWORD}}
subject: "FAILED: ${{github.repository}} run job"
body: GitHub Actions run job for ${{github.repository}} failed!
to: ${{vars.HDX_PIPELINE_EMAIL_LIST}}
from: ${{secrets.HDX_PIPELINE_EMAIL_FROM}}

workflow-keepalive:
if: github.event_name == 'schedule'
runs-on: ubuntu-latest
permissions:
actions: write
steps:
- uses: liskin/gh-workflow-keepalive@v1
49 changes: 49 additions & 0 deletions .github/workflows/run-python-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# This workflow will install Python dependencies, lint and run tests
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Run tests

on:
workflow_dispatch: # add run button in github
push:
branches-ignore:
- gh-pages
- 'dependabot/**'
pull_request:
branches-ignore:
- gh-pages

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install Hatch
uses: pypa/hatch@install
- name: Test with hatch/pytest
env:
HDX_KEY_TEST: ${{ secrets.HDX_BOT_SCRAPERS_API_TOKEN }}
GSHEET_AUTH: ${{ secrets.GSHEET_AUTH }}
run: |
hatch test
- name: Check styling
if: always()
run: |
hatch fmt --check
- name: Publish Unit Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
junit_files: test-results.xml
- name: Publish in Coveralls
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
flag-name: tests
format: lcov
104 changes: 93 additions & 11 deletions .gitignore
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ __pycache__/

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
Expand All @@ -20,9 +19,12 @@ lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
Expand All @@ -37,14 +39,17 @@ pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover
*.cover
*.py,cover
.hypothesis/
tests/*.log
.pytest_cache/
cover/

# Translations
*.mo
Expand All @@ -53,6 +58,8 @@ tests/*.log
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
Expand All @@ -63,29 +70,104 @@ instance/

# Sphinx documentation
docs/_build/
documentation/

# PyBuilder
.pybuilder/
target/

# IPython Notebook
# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version
# IPython
profile_default/
ipython_config.py

# celery beat schedule file
# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
.pdm.toml
.pdm-python
.pdm-build/

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# dotenv
.env
# SageMath parsed files
*.sage.py

# virtualenv
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
.idea/

## Project

# Directory where the scraper caches data
saved_data/

# Version file
**/_version.py

# Mac files
.DS_Store
7 changes: 0 additions & 7 deletions Dockerfile

This file was deleted.

4 changes: 2 additions & 2 deletions LICENSE
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)
MIT License

Copyright (c) 2016 Michael Rans
Copyright (c) 2024 UN-OCHA Humanitarian Data Exchange Project

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
Loading

0 comments on commit b833613

Please sign in to comment.