-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #810 from rkingsbury/rufflint
Linting, CI, dependencies, and infrastructure updates
- Loading branch information
Showing
83 changed files
with
935 additions
and
1,616 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,29 @@ | ||
*Start with a description of this PR. Then edit the list below to the items that make sense for your PR scope, and check off the boxes as you go!* | ||
## Summary | ||
|
||
## Contributor Checklist | ||
Major changes: | ||
|
||
- [ ] I have broken down my PR scope into the following TODO tasks | ||
- [ ] task 1 | ||
- [ ] task 2 | ||
- feature 1: ... | ||
- fix 1: ... | ||
|
||
## Todos | ||
|
||
If this is work in progress, what else needs to be done? | ||
|
||
- feature 2: ... | ||
- fix 2: | ||
|
||
## Checklist | ||
|
||
- [ ] Google format doc strings added. | ||
- [ ] Code linted with `ruff`. (For guidance in fixing rule violates, see [rule list](https://beta.ruff.rs/docs/rules/)) | ||
- [ ] Type annotations included. Check with `mypy`. | ||
- [ ] Tests added for new features/fixes. | ||
- [ ] I have run the tests locally and they passed. | ||
- [ ] I have added tests, or extended existing tests, to cover any new features or bugs fixed in this PR | ||
<!-- - [ ] If applicable, new classes/functions/modules have [`duecredit`](https://github.com/duecredit/duecredit) `@due.dcite` decorators to reference relevant papers by DOI ([example](https://github.com/materialsproject/pymatgen/blob/91dbe6ee9ed01d781a9388bf147648e20c6d58e0/pymatgen/core/lattice.py#L1168-L1172)) --> | ||
|
||
Tip: Install `pre-commit` hooks to auto-check types and linting before every commit: | ||
|
||
```sh | ||
pip install -U pre-commit | ||
pre-commit install | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
# https://www.oddbird.net/2022/06/01/dependabot-single-pull-request/ | ||
# https://github.com/materialsproject/MPContribs/blob/master/.github/workflows/upgrade-dependencies.yml | ||
name: upgrade dependencies | ||
|
||
on: | ||
workflow_dispatch: # Allow running on-demand | ||
schedule: | ||
# Runs every Monday at 8:00 UTC (4:00 Eastern) | ||
- cron: '0 8 * * 1' | ||
|
||
jobs: | ||
upgrade: | ||
name: ${{ matrix.package }} (${{ matrix.os }}/py${{ matrix.python-version }}) | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: ['ubuntu-latest', 'macos-latest', windows-latest] | ||
package: ["maggma"] | ||
python-version: ["3.8", "3.9", "3.10", "3.11"] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
cache: 'pip' | ||
- name: Upgrade Python dependencies | ||
shell: bash | ||
run: | | ||
python${{ matrix.python-version }} -m pip install --upgrade pip pip-tools | ||
cd ${{ matrix.package }} | ||
python${{ matrix.python-version }} -m piptools compile -q --upgrade --resolver=backtracking -o requirements/${{ matrix.os }}_py${{ matrix.python-version }}.txt | ||
python${{ matrix.python-version }} -m piptools compile -q --upgrade --resolver=backtracking --all-extras -o requirements/${{ matrix.os }}_py${{ matrix.python-version }}_extras.txt | ||
- name: Detect changes | ||
id: changes | ||
shell: bash | ||
run: | | ||
#git diff-index HEAD ${{ matrix.package }}/requirements/${{ matrix.os }}_py${{ matrix.python-version }}*.txt | awk '{print $4}' | sort -u | ||
#sha1=$(git diff-index HEAD ${{ matrix.package }}/requirements/${{ matrix.os }}_py${{ matrix.python-version }}*.txt | awk '{print $4}' | sort -u | head -n1) | ||
#[[ $sha1 == "0000000000000000000000000000000000000000" ]] && git update-index --really-refresh ${{ matrix.package }}/requirements/${{ matrix.os }}_py${{ matrix.python-version }}*.txt | ||
echo "count=$(git diff-index HEAD ${{ matrix.package }}/requirements/${{ matrix.os }}_py${{ matrix.python-version }}*.txt | wc -l | xargs)" >> $GITHUB_OUTPUT | ||
echo "files=$(git ls-files --exclude-standard --others ${{ matrix.package }}/requirements/${{ matrix.os }}_py${{ matrix.python-version }}*.txt | wc -l | xargs)" >> $GITHUB_OUTPUT | ||
- name: commit & push changes | ||
if: steps.changes.outputs.count > 0 || steps.changes.outputs.files > 0 | ||
shell: bash | ||
run: | | ||
git config user.name github-actions | ||
git config user.email [email protected] | ||
git add ${{ matrix.package }}/requirements | ||
git commit -m "update dependencies for ${{ matrix.package }} (${{ matrix.os }}/py${{ matrix.python-version }})" | ||
git push -f origin ${{ github.ref_name }}:auto-dependency-upgrades-${{ matrix.package }}-${{ matrix.os }}-py${{ matrix.python-version }} | ||
pull_request: | ||
name: Merge all branches and open PR | ||
runs-on: ubuntu-latest | ||
needs: upgrade | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- name: detect auto-upgrade-dependency branches | ||
id: changes | ||
run: echo "count=$(git branch -r | grep auto-dependency-upgrades- | wc -l | xargs)" >> $GITHUB_OUTPUT | ||
- name: merge all auto-dependency-upgrades branches | ||
if: steps.changes.outputs.count > 0 | ||
run: | | ||
git config user.name github-actions | ||
git config user.email [email protected] | ||
git checkout -b auto-dependency-upgrades | ||
git branch -r | grep auto-dependency-upgrades- | xargs -I {} git merge {} | ||
git rebase ${GITHUB_REF##*/} | ||
git push -f origin auto-dependency-upgrades | ||
git branch -r | grep auto-dependency-upgrades- | cut -d/ -f2 | xargs -I {} git push origin :{} | ||
- name: Open pull request if needed | ||
if: steps.changes.outputs.count > 0 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.PAT }} | ||
# Only open a PR if the branch is not attached to an existing one | ||
run: | | ||
PR=$(gh pr list --head auto-dependency-upgrades --json number -q '.[0].number') | ||
if [ -z $PR ]; then | ||
gh pr create \ | ||
--head auto-dependency-upgrades \ | ||
--title "Automated dependency upgrades" \ | ||
--body "Full log: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" | ||
else | ||
echo "Pull request already exists, won't create a new one." | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.