Skip to content

Commit

Permalink
Merge pull request #22 from lsst-sqre/tickets/DM-42008
Browse files Browse the repository at this point in the history
tickets/DM-42008: modernize lsst-rsp
  • Loading branch information
athornton authored Dec 12, 2023
2 parents 1586ee8 + d98af6b commit badc1c9
Show file tree
Hide file tree
Showing 35 changed files with 613 additions and 422 deletions.
7 changes: 7 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[flake8]
max-line-length = 79
# E203: whitespace before :, flake8 disagrees with PEP-8
# W503: line break after binary operator, flake8 disagrees with PEP-8
ignore = E203, W503
exclude =
docs/conf.py
1 change: 1 addition & 0 deletions .github/CODE_OF_CONDUCT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Please see the [Team Culture and Conduct Standards](https://developer.lsst.io/team/code-of-conduct.html) for LSST Data Management.
16 changes: 16 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Thanks for contributing to lsst-rsp.

## Support

If you are a Rubin Observatory staff member, please reach out of us on Slack in the #dm-square channel or create a Jira ticket.

If you are a community member, feel free to create a GitHub issue and we'll do our best to help you.

## Pull requests

Since lsst-rsp is built for the Vera C. Rubin Observatory and Legacy Survey of Space and Time, community contributions can only be accepted if they align with the Rubin Observatory's mission.
For that reason, it's a good idea to propose changes with a new GitHub issue before investing time in making a pull request.

* * *

See also our [Code of Conduct](./CODE_OF_CONDUCT).
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ updates:
schedule:
interval: "weekly"

- package-ecosystem: "docker"
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "weekly"
98 changes: 59 additions & 39 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,77 +1,97 @@
name: CI
name: Python CI

"on":
merge_group: {}
pull_request: {}
push:
branches-ignore:
# These should always correspond to pull requests, so ignore them for
# the push trigger and let them be triggered by the pull_request
# trigger, avoiding running the workflow twice. This is a minor
# optimization so there's no need to ensure this is comprehensive.
- "dependabot/**"
- "gh-readonly-queue/**"
- "renovate/**"
- "tickets/**"
- "u/**"
tags:
- "*"
pull_request: {}
release:
types: [published]

jobs:
lint:

runs-on: ubuntu-latest
timeout-minutes: 5

steps:
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"

- name: Run pre-commit
uses: pre-commit/[email protected]

test:

runs-on: ubuntu-latest
timeout-minutes: 10

strategy:
matrix:
python:
- "3.10"
- "3.11"

steps:
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
- name: Run tox
uses: lsst-sqre/run-tox@v1
with:
python-version: ${{ matrix.python }}
tox-envs: "py,typing"

- name: Run pre-commit
uses: pre-commit/[email protected]

- name: Install tox
run: pip install tox
test-packaging:

name: Test packaging
runs-on: ubuntu-latest

- name: Cache tox environments
id: cache-tox
uses: actions/cache@v3
steps:
- uses: actions/checkout@v3
with:
path: .tox
key: tox-${{ matrix.python }}-${{ hashFiles('setup.cfg') }}-${{ hashFiles('pyproject.toml') }}
restore-keys: |
tox-${{ matrix.python }}-${{ hashFiles('setup.cfg') }}-
fetch-depth: 0 # full history for setuptools_scm

- name: Build and publish
uses: lsst-sqre/build-and-publish-to-pypi@v2
with:
python-version: "3.11"
upload: false

- name: Run tox
run: tox -e py,coverage-report,typing
pypi:

# This job requires set up:
# 1. Set up a trusted publisher for PyPI
# 2. Set up a "pypi" environment in the repository
# See https://github.com/lsst-sqre/build-and-publish-to-pypi
name: Upload release to PyPI
runs-on: ubuntu-latest
needs: [test]
if: startsWith(github.ref, 'refs/tags/')
needs: [lint, test, test-packaging]
environment:
name: pypi
url: https://pypi.org/p/lsst-rsp
permissions:
id-token: write
if: github.event_name == 'release' && github.event.action == 'published'

steps:
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
cache: "pip"
cache-dependency-path: "setup.cfg"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --upgrade setuptools wheel twine
fetch-depth: 0 # full history for setuptools_scm

- name: Build and publish
env:
TWINE_USERNAME: "__token__"
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel --universal
twine upload dist/*
uses: lsst-sqre/build-and-publish-to-pypi@v2
with:
python-version: "3.11"
33 changes: 33 additions & 0 deletions .github/workflows/dependencies.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Dependency Update

"on":
schedule:
- cron: "0 12 * * 1"
workflow_dispatch: {}

jobs:
update:
runs-on: ubuntu-latest
timeout-minutes: 10

steps:
- uses: actions/checkout@v3

- name: Run neophile
uses: lsst-sqre/run-neophile@v1
with:
python-version: "3.11"
mode: pr
types: pre-commit
app-id: ${{ secrets.NEOPHILE_APP_ID }}
app-secret: ${{ secrets.NEOPHILE_PRIVATE_KEY }}

- name: Report status
if: always()
uses: ravsamhq/notify-slack-action@v2
with:
status: ${{ job.status }}
notify_when: "failure"
notification_title: "Periodic dependency update for {repo} failed"
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_ALERT_WEBHOOK }}
58 changes: 58 additions & 0 deletions .github/workflows/periodic-ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# This is a separate run of the Python test suite that doesn't cache the tox
# environment and runs from a schedule. The purpose is to test compatibility
# with the latest versions of dependencies.

name: Periodic CI

"on":
schedule:
- cron: "0 12 * * 1"

jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 10

strategy:
matrix:
python:
- "3.11"

steps:
- uses: actions/checkout@v3

- name: Run tests in tox
uses: lsst-sqre/run-tox@v1
with:
python-version: ${{ matrix.python }}
tox-envs: "lint,typing,py"
use-cache: false

docs:
runs-on: ubuntu-latest
timeout-minutes: 10

steps:
- uses: actions/checkout@v3

- name: Build docs in tox
uses: lsst-sqre/run-tox@v1
with:
python-version: "3.11"
tox-envs: "docs,docs-linkcheck"
use-cache: false

test-packaging:
runs-on: ubuntu-latest
timeout-minutes: 10

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # full history for setuptools_scm

- name: Build and publish
uses: lsst-sqre/build-and-publish-to-pypi@v2
with:
python-version: "3.11"
upload: false
10 changes: 3 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ instance/

# Sphinx documentation
docs/_build/
docs/api/

# PyBuilder
target/
Expand All @@ -82,9 +83,7 @@ profile_default/
ipython_config.py

# 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
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
Expand Down Expand Up @@ -130,8 +129,5 @@ dmypy.json
# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Mac metadata
# MacOS desktop
.DS_Store
23 changes: 18 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,35 @@ repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: trailing-whitespace
- id: check-yaml
- id: check-toml

- repo: https://github.com/pycqa/isort
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort
additional_dependencies:
- toml
additional_dependencies: [toml]

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

- repo: https://github.com/pycqa/flake8
- repo: https://github.com/asottile/blacken-docs
rev: v1.12.1
hooks:
- id: blacken-docs
additional_dependencies: [black==23.3.0]
args: [-l, "79", -t, py38]

- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
hooks:
- id: flake8

- repo: https://github.com/PyCQA/pydocstyle
rev: 6.3.0
hooks:
- id: pydocstyle
additional_dependencies: [toml]
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Change log

lsst-rsp is versioned with [semver](https://semver.org/).

Find changes for the upcoming release in the project's [changelog.d directory](https://github.com/lsst-sqre/lsst-rsp/tree/main/changelog.d/).

<!-- scriv-insert-here -->
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021 LSST SQuaRE
Copyright (c) 2021-2023 Association of Universities for Research in Astronomy, Inc. (AURA)

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
30 changes: 26 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,29 @@
.PHONY: help
help:
@echo "Make targets for lsst-rsp:"
@echo "make clean - Remove generated files"
@echo "make init - Set up dev environment (install pre-commit hooks)"
@echo "make linkcheck - Check for broken links in documentation"

.PHONY: clean
clean:
rm -rf .tox
rm -rf docs/_build
rm -rf docs/api

.PHONY: init
init:
pip install --upgrade pip pre-commit setuptools wheel
pip install --upgrade --editable .
rm -rf .tox
pip install --upgrade tox
pip install --upgrade pip tox pre-commit
pip install --upgrade -e ".[dev]"
pre-commit install
rm -rf .tox

# This is defined as a Makefile target instead of only a tox command because
# if the command fails we want to cat output.txt, which contains the
# actually useful linkcheck output. tox unfortunately doesn't support this
# level of shell trickery after failed commands.
.PHONY: linkcheck
linkcheck:
sphinx-build --keep-going -n -W -T -b linkcheck docs \
docs/_build/linkcheck \
|| (cat docs/_build/linkcheck/output.txt; exit 1)
Loading

0 comments on commit badc1c9

Please sign in to comment.