forked from os-climate/corporate_data_extraction
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'os-climate:main' into main
- Loading branch information
Showing
10 changed files
with
681 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[flake8] | ||
#ignore = E226,E302,E41 | ||
max-line-length = 120 | ||
exclude = tests/* | ||
max-complexity = 10 |
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,56 @@ | ||
--- | ||
name: "🧪 Test builds (matrix)" | ||
|
||
on: # yamllint disable-line rule:truthy | ||
workflow_dispatch: | ||
pull_request: | ||
types: | ||
[opened, reopened, edited] | ||
|
||
jobs: | ||
pre-release: | ||
# Don't run if pull request is NOT merged | ||
if: github.event.pull_request.merged == true | ||
runs-on: "ubuntu-latest" | ||
continue-on-error: true | ||
strategy: | ||
matrix: | ||
python-version: ['3.9', '3.10', '3.11'] | ||
steps: | ||
|
||
- name: "Populate environment variables" | ||
id: setenv | ||
run: | | ||
echo "Action triggered by user: ${GITHUB_TRIGGERING_ACTOR}" | ||
set -x | ||
datetime=$(date +'%Y%m%d%H%M') | ||
export datetime | ||
echo "datetime=${datetime}" >> "$GITHUB_OUTPUT" | ||
vernum="${{ matrix.python-version }}.${datetime}" | ||
echo "vernum=${vernum}" >> "$GITHUB_OUTPUT" | ||
- name: "Checkout repository" | ||
uses: actions/checkout@v3 | ||
|
||
- name: "Set up Python ${{ matrix.python-version }}" | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: "Install dependencies" | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install tox tox-gh-actions | ||
- name: "Tag for test release" | ||
# Delete all local tags, then create a synthetic tag for testing | ||
# Use the date/time to avoid conflicts uploading to Test PyPI | ||
run: | | ||
scripts/dev-versioning.sh "${{ steps.setenv.outputs.vernum }}" | ||
git tag | xargs -L 1 | xargs git tag --delete | ||
git tag "v${{ steps.setenv.outputs.vernum }}" | ||
git checkout "tags/v${{ steps.setenv.outputs.vernum }}" | ||
grep version pyproject.toml | ||
- name: "Build with TOX" | ||
run: | | ||
tox -e build |
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,51 @@ | ||
--- | ||
name: "🧪 Linting checks" | ||
|
||
# yamllint disable-line rule:truthy | ||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
types: | ||
[opened, reopened, edited] | ||
|
||
jobs: | ||
lint: | ||
name: "Check repository content" | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
||
- name: "Checkout repository" | ||
uses: actions/checkout@v3 | ||
|
||
- name: "Checking YAML files (yamllint)" | ||
if: always() | ||
run: | | ||
pip install yamllint | ||
yamllint . | ||
# - name: "Checking TOML files (gh-action-toml-linter)" | ||
# if: always() | ||
# uses: yisonPylkita/[email protected] | ||
|
||
- name: "Checking GitHub Actions (actionlint)" | ||
if: always() | ||
id: actionlint | ||
uses: raven-actions/actionlint@v1 | ||
with: | ||
matcher: true # optional | ||
cache: true # optional | ||
fail-on-error: true # optional | ||
files: ".github/workflows/*.yaml, .github/workflows/*.yml" | ||
# flags: "-ignore SC2086" # optional | ||
|
||
- name: "Problem report (conditional step)" | ||
if: ${{ steps.actionlint.outputs.exit-code != 0 }} | ||
# yamllint disable rule:line-length | ||
run: | | ||
echo "Used actionlint version ${{ steps.actionlint.outputs.version-semver }}" | ||
echo "Used actionlint release ${{ steps.actionlint.outputs.version-tag }}" | ||
echo "actionlint ended with ${{ steps.actionlint.outputs.exit-code }} exit code" | ||
echo "actionlint ended because '${{ steps.actionlint.outputs.exit-message }}'" | ||
echo "actionlint found ${{ steps.actionlint.outputs.total-errors }} errors" | ||
echo "actionlint checked ${{ steps.actionlint.outputs.total-files }} files" | ||
echo "actionlint cache used: ${{ steps.actionlint.outputs.cache-hit }}" |
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,172 @@ | ||
--- | ||
name: "🐍📦 Production build and release" | ||
|
||
# GitHub/PyPI trusted publisher documentation: | ||
# https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/ | ||
|
||
# yamllint disable-line rule:truthy | ||
on: | ||
# workflow_dispatch: | ||
push: | ||
# Only invoked on release tag pushes | ||
tags: | ||
- v*.*.* | ||
|
||
env: | ||
python-version: "3.10" | ||
|
||
|
||
### BUILD ### | ||
|
||
jobs: | ||
build: | ||
name: "🐍 Build packages" | ||
runs-on: ubuntu-latest | ||
permissions: | ||
# IMPORTANT: mandatory for Sigstore | ||
id-token: write | ||
steps: | ||
|
||
### BUILDING ### | ||
|
||
- name: "Checkout repository" | ||
uses: actions/checkout@v4 | ||
|
||
- name: "Setup PDM for build commands" | ||
uses: pdm-project/setup-pdm@v3 | ||
|
||
- name: "Setup Python 3.10" | ||
uses: actions/[email protected] | ||
with: | ||
python-version: ${{ env.python-version }} | ||
|
||
- name: "Update version from tags for production release" | ||
run: | | ||
echo "Github versioning: ${{ github.ref_name }}" | ||
scripts/release-versioning.sh | ||
- name: "Build with PDM backend" | ||
run: | | ||
pdm build | ||
### SIGNING ### | ||
|
||
- name: "Sign packages with Sigstore" | ||
uses: sigstore/[email protected] | ||
with: | ||
inputs: >- | ||
./dist/*.tar.gz | ||
./dist/*.whl | ||
- name: Store the distribution packages | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: ${{ github.ref_name }} | ||
path: dist/ | ||
|
||
|
||
### PUBLISH GITHUB ### | ||
|
||
github: | ||
name: "📦 Publish to GitHub" | ||
# Only publish on tag pushes | ||
if: startsWith(github.ref, 'refs/tags/') | ||
needs: | ||
- build | ||
runs-on: ubuntu-latest | ||
permissions: | ||
# IMPORTANT: mandatory to publish artefacts | ||
contents: write | ||
steps: | ||
|
||
- name: "⬇ Download build artefacts" | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: ${{ github.ref_name }} | ||
path: dist/ | ||
|
||
- name: "📦 Publish release to GitHub" | ||
uses: ModeSevenIndustrialSolutions/action-automatic-releases@latest | ||
with: | ||
# Valid inputs are: | ||
# repo_token, automatic_release_tag, draft, prerelease, title, files | ||
repo_token: ${{ secrets.GITHUB_TOKEN }} | ||
prerelease: false | ||
automatic_release_tag: ${{ github.ref_name }} | ||
title: ${{ github.ref_name }} | ||
files: | | ||
dist/*.tar.gz | ||
dist/*.whl | ||
### PUBLISH PYPI TEST ### | ||
|
||
testpypi: | ||
name: "📦 Publish to PyPi Test" | ||
# Only publish on tag pushes | ||
if: startsWith(github.ref, 'refs/tags/') | ||
needs: | ||
- build | ||
runs-on: ubuntu-latest | ||
environment: | ||
name: testpypi | ||
permissions: | ||
# IMPORTANT: mandatory for trusted publishing | ||
id-token: write | ||
steps: | ||
|
||
- name: "⬇ Download build artefacts" | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: ${{ github.ref_name }} | ||
path: dist/ | ||
|
||
- name: "Remove files unsupported by PyPi" | ||
run: | | ||
if [ -f dist/buildvars.txt ]; then | ||
rm dist/buildvars.txt | ||
fi | ||
rm dist/*.crt dist/*.sig* | ||
- name: Publish distribution to Test PyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
with: | ||
repository-url: https://test.pypi.org/legacy/ | ||
verbose: true | ||
|
||
### PUBLISH PYPI ### | ||
|
||
pypi: | ||
name: "📦 Publish to PyPi" | ||
# Only publish on tag pushes | ||
if: startsWith(github.ref, 'refs/tags/') | ||
needs: | ||
- testpypi | ||
runs-on: ubuntu-latest | ||
environment: | ||
name: pypi | ||
permissions: | ||
# IMPORTANT: mandatory for trusted publishing | ||
id-token: write | ||
steps: | ||
|
||
- name: "⬇ Download build artefacts" | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: ${{ github.ref_name }} | ||
path: dist/ | ||
|
||
- name: "Remove files unsupported by PyPi" | ||
run: | | ||
if [ -f dist/buildvars.txt ]; then | ||
rm dist/buildvars.txt | ||
fi | ||
rm dist/*.crt dist/*.sig* | ||
- name: "Setup PDM for build commands" | ||
uses: pdm-project/setup-pdm@v3 | ||
|
||
- name: "Publish release to PyPI" | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
with: | ||
verbose: true |
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,41 @@ | ||
--- | ||
# This workflow will install Python dependencies | ||
# run tests and lint with a variety of Python versions | ||
# For more information see: | ||
# https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions | ||
|
||
name: "⛔️ Security auditing" | ||
|
||
on: # yamllint disable-line rule:truthy | ||
workflow_dispatch: | ||
pull_request: | ||
types: | ||
[opened, reopened, edited] | ||
|
||
jobs: | ||
build: | ||
name: "Audit Python dependencies" | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: ['3.9', '3.10', '3.11'] | ||
steps: | ||
|
||
- name: "Checkout repository" | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: "Install dependencies" | ||
run: | | ||
pip install --upgrade pip | ||
find ./* -name requirements.txt -exec pip install --upgrade -r {} \; | ||
- name: "Run: pip-audit" | ||
uses: pypa/[email protected] | ||
with: | ||
ignore-vulns: | | ||
PYSEC-2023-163 |
Oops, something went wrong.