From 848e98483d8f000ba6737a5172ae9f33e96951fb Mon Sep 17 00:00:00 2001 From: LilSpazJoekp <15524072+LilSpazJoekp@users.noreply.github.com> Date: Mon, 26 Dec 2022 17:47:59 -0600 Subject: [PATCH] Consolidate GitHub Actions workflows --- .github/workflows/ci.yml | 124 +------------------- .github/workflows/manual_tag_release.yml | 42 +------ .github/workflows/pre-commit_autoupdate.yml | 28 +---- .github/workflows/prepare_release.yml | 45 +------ .github/workflows/pypi.yml | 25 +--- .github/workflows/scorecards-analysis.yml | 57 ++------- .github/workflows/set_active_docs.yml | 9 ++ .github/workflows/set_active_versions.yml | 21 ---- .github/workflows/stale-action.yml | 27 ----- .github/workflows/stale_action.yml | 10 ++ .github/workflows/tag_release.yml | 42 +------ 11 files changed, 59 insertions(+), 371 deletions(-) create mode 100644 .github/workflows/set_active_docs.yml delete mode 100644 .github/workflows/set_active_versions.yml delete mode 100644 .github/workflows/stale-action.yml create mode 100644 .github/workflows/stale_action.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 05a8c7369..ae5648450 100644 --- a/.github/workflows/ci.yml +++ b/.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 ] diff --git a/.github/workflows/manual_tag_release.yml b/.github/workflows/manual_tag_release.yml index afbc8c4f0..6145d4a43 100644 --- a/.github/workflows/manual_tag_release.yml +++ b/.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 diff --git a/.github/workflows/pre-commit_autoupdate.yml b/.github/workflows/pre-commit_autoupdate.yml index 9612d1a56..15654bb5e 100644 --- a/.github/workflows/pre-commit_autoupdate.yml +++ b/.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: diff --git a/.github/workflows/prepare_release.yml b/.github/workflows/prepare_release.yml index e7ec602d6..4b3472aa0 100644 --- a/.github/workflows/prepare_release.yml +++ b/.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 diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml index a0dc8bd5e..35525bd8c 100644 --- a/.github/workflows/pypi.yml +++ b/.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 ] diff --git a/.github/workflows/scorecards-analysis.yml b/.github/workflows/scorecards-analysis.yml index 8f927ea86..2af43c8a5 100644 --- a/.github/workflows/scorecards-analysis.yml +++ b/.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 diff --git a/.github/workflows/set_active_docs.yml b/.github/workflows/set_active_docs.yml new file mode 100644 index 000000000..af422e67b --- /dev/null +++ b/.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 ] diff --git a/.github/workflows/set_active_versions.yml b/.github/workflows/set_active_versions.yml deleted file mode 100644 index f5b978303..000000000 --- a/.github/workflows/set_active_versions.yml +++ /dev/null @@ -1,21 +0,0 @@ -jobs: - set_active_docs: - name: Set Active Docs - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - with: - python-version: '3.x' - - name: Install dependencies - run: pip install packaging requests - - env: - READTHEDOCS_TOKEN: ${{ secrets.READTHEDOCS_TOKEN }} - name: Set Active Docs - run: python tools/set_active_docs.py -name: Set Active Docs -on: - workflow_run: - workflows: ["Upload Python Package"] - types: - - completed diff --git a/.github/workflows/stale-action.yml b/.github/workflows/stale-action.yml deleted file mode 100644 index 50c15445b..000000000 --- a/.github/workflows/stale-action.yml +++ /dev/null @@ -1,27 +0,0 @@ -env: - days-before-close: 30 - days-before-stale: 30 - stale-close-label: 'Auto-closed - Stale' -jobs: - stale: - runs-on: ubuntu-latest - steps: - - uses: actions/stale@v3 - with: - close-issue-label: ${{ env.stale-close-label }} - close-issue-message: 'This issue was closed because it has been stale for ${{ env.days-before-close }} days with no activity.' - close-pr-label: ${{ env.stale-close-label }} - close-pr-message: 'This PR was closed because it has been stale for ${{ env.days-before-close }} days with no activity.' - days-before-close: ${{ env.days-before-close }} - days-before-stale: ${{ env.days-before-stale }} - exempt-all-assignees: true - exempt-all-milestones: true - exempt-draft-pr: true - exempt-issue-labels: 'Discussion' - exempt-pr-labels: 'Discussion' - stale-issue-message: 'This issue is stale because it has been open for ${{ env.days-before-stale }} days with no activity. Remove the Stale label or comment or this will be closed in ${{ env.days-before-close }} days.' - stale-pr-message: 'This PR is stale because it has been open for ${{ env.days-before-stale }} days with no activity. Remove the Stale label or comment or this will be closed in ${{ env.days-before-close }} days.' -name: 'Close stale issues and PRs' -on: - schedule: - - cron: '0 */6 * * *' diff --git a/.github/workflows/stale_action.yml b/.github/workflows/stale_action.yml new file mode 100644 index 000000000..3bf3ec6fa --- /dev/null +++ b/.github/workflows/stale_action.yml @@ -0,0 +1,10 @@ +jobs: + stale_action: + name: Close stale issues and PRs + secrets: inherit + uses: praw-dev/.github/.github/workflows/stale_action.yml@main +name: Close stale issues and PRs +on: + schedule: + - cron: 0 */6 * * * + workflow_dispatch: diff --git a/.github/workflows/tag_release.yml b/.github/workflows/tag_release.yml index bd0ca7819..cb2983b1d 100644 --- a/.github/workflows/tag_release.yml +++ b/.github/workflows/tag_release.yml @@ -1,43 +1,9 @@ jobs: - release_tag: - if: "startsWith(github.event.head_commit.message, 'Merge pull request #') && contains(github.event.head_commit.message, ' from praw-dev/prepare_release_v')" + tag_release: name: Tag Release - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 3 - 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 HEAD^2^ - 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 - - 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/tag_release.yml@main name: Tag Release on: push: - branches: - - master - - release_test + branches: [ master, release_test ]