Skip to content

Commit

Permalink
Consolidate GitHub Actions workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
LilSpazJoekp committed Jan 2, 2023
1 parent 2a57534 commit 848e984
Show file tree
Hide file tree
Showing 11 changed files with 59 additions and 371 deletions.
124 changes: 6 additions & 118 deletions .github/workflows/ci.yml
@@ -1,121 +1,9 @@
jobs:
complete_coveralls:
needs: test-multi-python
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true
lint-multi-os:
name: Lint ${{ matrix.os }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.x
- uses: actions/cache@v1
with:
key: v0-${{ runner.os }}-pip-lint-${{ hashFiles('setup.py') }}
path: ~/.cache/pip
restore-keys: |
v0-${{ runner.os }}-pip-lint-
v0-${{ runner.os }}-pip-
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
pip install .[lint]
- name: Run pre-commit hooks
uses: pre-commit/action@v2.0.3
- name: Run sphinx
run: sphinx-build -W --keep-going docs/ /tmp/foo
strategy:
matrix:
os: [ macOS-latest, ubuntu-latest, windows-latest ]
test-multi-os:
name: Test ${{ matrix.os }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.x
- uses: actions/cache@v1
with:
key: v0-${{ runner.os }}-pip-test-${{ hashFiles('setup.py') }}
path: ~/.cache/pip
restore-keys: |
v0-${{ runner.os }}-pip-test-
v0-${{ runner.os }}-pip-
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install .[test]
- name: Test with pytest
env:
ENSURE_NO_UNUSED_CASSETTES: 1
run: pytest
strategy:
matrix:
os: [ macOS-latest, ubuntu-latest, windows-latest ]
test-multi-python:
name: Test Python ${{ matrix.python-version }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- uses: actions/cache@v1
with:
key: v0-${{ runner.os }}-pip-test-${{ hashFiles('setup.py') }}
path: ~/.cache/pip
restore-keys: |
v0-${{ runner.os }}-pip-test-
v0-${{ runner.os }}-pip-
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install .[ci,test]
- name: Test with pytest
run: coverage run --source praw --module pytest
env:
ENSURE_NO_UNUSED_CASSETTES: 1
- name: Submit to coveralls
env:
COVERALLS_PARALLEL: true
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: coveralls --service=github
- name: Check coverage
run: coverage report -m --fail-under=100
strategy:
matrix:
python-version: [ "3.7", "3.8", "3.9", "3.10", "3.11" ]
test-network:
name: Test Network Request
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.x
- uses: actions/cache@v1
with:
key: v0-${{ runner.os }}-pip-test-${{ hashFiles('setup.py') }}
path: ~/.cache/pip
restore-keys: |
v0-${{ runner.os }}-pip-test-
v0-${{ runner.os }}-pip-
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install .[test]
- name: Run network test
run: pytest tests/integration/test_github_actions.py::test_github_actions
env:
NETWORK_TEST_CLIENT_ID: ${{ secrets.NETWORK_TEST_CLIENT_ID }}
NETWORK_TEST_CLIENT_SECRET: ${{ secrets.NETWORK_TEST_CLIENT_SECRET }}
ci:
name: CI
secrets: inherit
uses: praw-dev/.github/.github/workflows/ci.yml@main
with:
package: praw
name: CI
on: [ pull_request, push ]
42 changes: 6 additions & 36 deletions .github/workflows/manual_tag_release.yml
@@ -1,44 +1,14 @@
jobs:
release_tag:
manual_tag_release:
name: Manual Tag Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
ssh-key: ${{ secrets.SSH_DEPLOY_KEY }}
- uses: actions/setup-python@v2
with:
python-version: 3.x
- name: Install dependencies
run: pip install packaging docutils
- name: Extract Version
run: |
git checkout ${{ github.event.inputs.commit }}
echo "commit=$(git rev-parse HEAD)" >> $GITHUB_ENV
git log --format=%B -n 1 | ./tools/bump_version.py > tmp_version
echo "version=$(cat tmp_version)" >> $GITHUB_ENV
cat tmp_version | python -c 'import sys; from packaging import version; print(int(version.Version(sys.stdin.readline()).is_prerelease))' > tmp_is_prerelease
echo "is_prerelease=$(cat tmp_is_prerelease)" >> $GITHUB_ENV
git switch -
- name: Extract Change Log
run: |
echo ${{ env.version }} | ./tools/extract_log_entry.py > version_changelog
- env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
name: Create GitHub Release
uses: actions/create-release@v1
with:
body_path: version_changelog
commitish: ${{ env.commit }}
draft: true
prerelease: ${{ env.is_prerelease == '1' }}
release_name: v${{ env.version }}
tag_name: v${{ env.version }}
secrets: inherit
uses: praw-dev/.github/.github/workflows/manual_tag_release.yml@main
with:
commit: ${{ inputs.commit }}
name: Manual Tag Release
on:
workflow_dispatch:
inputs:
commit:
description: 'The commit the version bump occurred'
description: The commit the version bump occurred
required: true
28 changes: 6 additions & 22 deletions .github/workflows/pre-commit_autoupdate.yml
@@ -1,26 +1,10 @@
jobs:
auto-update:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install .[dev]
- name: Update hooks
run: pre-commit autoupdate
- name: Run hooks
run: pre-commit run --all-files
continue-on-error: true
- uses: peter-evans/create-pull-request@v3
with:
branch: update/pre-commit-hooks
title: Update pre-commit hooks
commit-message: "Update pre-commit hooks"
body: Update versions of pre-commit hooks to the latest version.
name: 'Update pre-commit hooks'
pre-commit_autoupdate:
name: Update pre-commit hooks
secrets: inherit
uses: praw-dev/.github/.github/workflows/pre-commit_autoupdate.yml@main
name: Update pre-commit hooks
on:
schedule:
- cron: '0 15 * * 1'
- cron: 0 15 * * 1
workflow_dispatch:
45 changes: 6 additions & 39 deletions .github/workflows/prepare_release.yml
@@ -1,47 +1,14 @@
jobs:
prepare_release:
name: Prepare Release v${{ github.event.inputs.version }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ssh-key: ${{ secrets.SSH_DEPLOY_KEY }}
- uses: actions/setup-python@v2
with:
python-version: 3.x
- name: Install dependencies
run: pip install packaging
- name: Prepare Git Variables
run: |
git config --global author.email ${{ github.actor }}@users.noreply.github.com
git config --global author.name ${{ github.actor }}
git config --global committer.email noreply@github.com
git config --global committer.name GitHub
- name: Set desired version
run: |
tools/set_version.py ${{ github.event.inputs.version }} > tmp_version
echo "version=$(cat tmp_version)" >> $GITHUB_ENV
- name: Commit desired version
run: git commit -am "Bump to v${{ env.version }}"
- name: Set development version
run: |
tools/set_version.py Unreleased > tmp_version
echo "dev_version=$(cat tmp_version)" >> $GITHUB_ENV
rm tmp_version
- name: Commit development version
run: git commit -am "Set development version v${{ env.dev_version }}"
- name: Create Pull Request
uses: peter-evans/create-pull-request@v3
with:
body:
branch: prepare_release_v${{ env.version }}
draft: false
title: Release v${{ env.version }}

name: Prepare Release
secrets: inherit
uses: praw-dev/.github/.github/workflows/prepare_release.yml@main
with:
commit: ${{ inputs.version }}
name: Prepare Release
on:
workflow_dispatch:
inputs:
version:
description: 'The version to prepare for release'
description: The version to prepare for release
required: true
25 changes: 5 additions & 20 deletions .github/workflows/pypi.yml
@@ -1,24 +1,9 @@
jobs:
release:
name: Build and release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
name: Build and release
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
pypi:
name: Upload Python Package
secrets: inherit
uses: praw-dev/.github/.github/workflows/pypi.yml@main
name: Upload Python Package
on:
release:
types: [published]
types: [ published ]
57 changes: 7 additions & 50 deletions .github/workflows/scorecards-analysis.yml
@@ -1,55 +1,12 @@
jobs:
scorecards-analysis:
name: Scorecards supply-chain security
secrets: inherit
uses: praw-dev/.github/.github/workflows/scorecards-analysis.yml@main
name: Scorecards supply-chain security
on:
# Only the default branch is supported.
branch_protection_rule:
schedule:
- cron: '39 11 * * 5'
push:
branches: [ master ]

# Declare default permissions as read only.
permissions: read-all

jobs:
analysis:
name: Scorecards analysis
runs-on: ubuntu-latest
permissions:
# Needed to upload the results to code-scanning dashboard.
security-events: write
actions: read
contents: read

steps:
- name: "Checkout code"
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 # v2.4.0
with:
persist-credentials: false

- name: "Run analysis"
uses: ossf/scorecard-action@c8416b0b2bf627c349ca92fc8e3de51a64b005cf # v1.0.2
with:
results_file: results.sarif
results_format: sarif
# Read-only PAT token. To create it,
# follow the steps in https://github.com/ossf/scorecard-action#pat-token-creation.
repo_token: ${{ secrets.SCORECARD_READ_TOKEN }}
# Publish the results to enable scorecard badges. For more details, see
# https://github.com/ossf/scorecard-action#publishing-results.
# For private repositories, `publish_results` will automatically be set to `false`,
# regardless of the value entered here.
publish_results: true

# Upload the results as artifacts (optional).
- name: "Upload artifact"
uses: actions/upload-artifact@82c141cc518b40d92cc801eee768e7aafc9c2fa2 # v2.3.1
with:
name: SARIF file
path: results.sarif
retention-days: 5

# Upload the results to GitHub's code scanning dashboard.
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@5f532563584d71fdef14ee64d17bafb34f751ce5 # v1.0.26
with:
sarif_file: results.sarif
schedule:
- cron: 30 1 * * 6
9 changes: 9 additions & 0 deletions .github/workflows/set_active_docs.yml
@@ -0,0 +1,9 @@
jobs:
set_active_docs:
name: Set Active Docs
secrets: inherit
uses: praw-dev/.github/.github/workflows/set_active_docs.yml@main
name: Set Active Docs
on:
release:
types: [ published ]
21 changes: 0 additions & 21 deletions .github/workflows/set_active_versions.yml

This file was deleted.

0 comments on commit 848e984

Please sign in to comment.