diff --git a/.github/workflows/dev_tests.yml b/.github/workflows/dev_tests.yml index 46e0362..ad2b7fc 100644 --- a/.github/workflows/dev_tests.yml +++ b/.github/workflows/dev_tests.yml @@ -1,12 +1,14 @@ name: dev tests on: + push: + branches: [ main ] pull_request: + types: [opened, synchronize, reopened] workflow_dispatch: schedule: - cron: '0 0 * * *' - permissions: contents: write issues: write @@ -34,7 +36,7 @@ jobs: CLIENT_ID: ${{ secrets.CLIENT_ID }} CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }} ENV : "dev" - run: pytest -r nmdc_api_utilities/test/ + run: pytest -x nmdc_api_utilities/test/ - name: Create Issue if: failure() && github.event.pull_request == null && github.event_name == 'schedule' uses: actions/github-script@v6 diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index e00a7ff..5cda01f 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -1,6 +1,10 @@ name: documentation -on: [push, pull_request, workflow_dispatch] +on: + push: + branches: [ main ] + pull_request: + workflow_dispatch: permissions: contents: write diff --git a/.github/workflows/precommit.yml b/.github/workflows/precommit.yml new file mode 100644 index 0000000..eb2ec85 --- /dev/null +++ b/.github/workflows/precommit.yml @@ -0,0 +1,48 @@ +name: Run pre-commit hooks & push changes + +on: + push: + branches: [ main ] + pull_request: + types: [opened, synchronize, reopened] + paths: + - '**.py' + + +permissions: + contents: write + + +jobs: + run-hooks: + name: Run Pre-Commit hooks and push changes back + runs-on: ubuntu-latest + steps: + - name: Checkout the code + uses: actions/checkout@v3 + with: + ref: ${{ github.event.pull_request.head.ref }} + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: 3.12 + + - name: Install pre-commit + run: | + python -m pip install --upgrade pip + python -m pip install pre-commit + + - name: Run pre-commit hooks + run: | + pre-commit run --all-files || true + + - name: Commit and push changes if pre-commit made any modifications + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + if [ -n "$(git status --porcelain)" ]; then + git add . + git commit -m "precommit: reformat" + git push + fi diff --git a/.github/workflows/prod_tests.yml b/.github/workflows/prod_tests.yml index 108cad5..60726b6 100644 --- a/.github/workflows/prod_tests.yml +++ b/.github/workflows/prod_tests.yml @@ -1,7 +1,10 @@ name: prod tests on: + push: + branches: [ main ] pull_request: + types: [opened, synchronize, reopened] workflow_dispatch: schedule: - cron: '0 0 * * *' @@ -33,7 +36,7 @@ jobs: CLIENT_ID: ${{ secrets.CLIENT_ID }} CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }} ENV : "prod" - run: pytest -r nmdc_api_utilities/test/ + run: pytest -x nmdc_api_utilities/test/ - name: Create Issue if: failure() && github.event.pull_request == null && github.event_name == 'schedule' uses: actions/github-script@v6 diff --git a/pyproject.toml b/pyproject.toml index 162d2e7..33d8297 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,5 +17,7 @@ classifiers = [ "Programming Language :: Python :: 3", "Operating System :: OS Independent", ] -dependencies = ["pandas~=2.2.3", "requests~=2.32.3", "matplotlib~=3.10.0"] license-files = ["LICENSE"] +dynamic = ["dependencies"] +[tool.setuptools.dynamic] +dependencies = {file = ["requirements.txt"]}