Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Github action workflows #7651

Merged
merged 10 commits into from Nov 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 6 additions & 7 deletions .github/workflows/changelog.yml
Expand Up @@ -5,8 +5,8 @@ on:
types: [opened, synchronize, labeled, unlabeled, reopened]

env:
# Also change CACHE_VERSION in the other workflows
CACHE_VERSION: 31
CACHE_VERSION: 1
KEY_PREFIX: base-venv
DEFAULT_PYTHON: "3.11"

permissions:
Expand All @@ -30,12 +30,13 @@ jobs:
uses: actions/setup-python@v4.3.0
with:
python-version: ${{ env.DEFAULT_PYTHON }}
check-latest: true
- name: Generate partial Python venv restore key
id: generate-python-key
run: >-
echo "key=base-venv-${{ env.CACHE_VERSION }}-${{
hashFiles('setup.cfg', 'requirements_test.txt', 'requirements_test_min.txt')
}}" >> $GITHUB_OUTPUT
echo "key=${{ env.KEY_PREFIX }}-${{ env.CACHE_VERSION }}-${{
hashFiles('pyproject.toml', 'requirements_test.txt',
'requirements_test_min.txt') }}" >> $GITHUB_OUTPUT
- name: Restore Python virtual environment
id: cache-venv
uses: actions/cache@v3.0.11
Expand All @@ -44,8 +45,6 @@ jobs:
key: >-
${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{
steps.generate-python-key.outputs.key }}
restore-keys: |
${{ runner.os }}-${{ steps.python.outputs.python-version }}-base-venv-${{ env.CACHE_VERSION }}-
- name: Create Python virtual environment
if: steps.cache-venv.outputs.cache-hit != 'true'
run: |
Expand Down
18 changes: 10 additions & 8 deletions .github/workflows/checks.yaml
Expand Up @@ -8,7 +8,8 @@ on:
pull_request: ~

env:
CACHE_VERSION: 31
CACHE_VERSION: 1
KEY_PREFIX: base-venv
DEFAULT_PYTHON: "3.11"
PRE_COMMIT_CACHE: ~/.cache/pre-commit

Expand All @@ -35,12 +36,13 @@ jobs:
uses: actions/setup-python@v4.3.0
with:
python-version: ${{ env.DEFAULT_PYTHON }}
check-latest: true
- name: Generate partial Python venv restore key
id: generate-python-key
run: >-
echo "key=base-venv-${{ env.CACHE_VERSION }}-${{
hashFiles('setup.cfg', 'requirements_test.txt', 'requirements_test_min.txt')
}}" >> $GITHUB_OUTPUT
echo "key=${{ env.KEY_PREFIX }}-${{ env.CACHE_VERSION }}-${{
hashFiles('pyproject.toml', 'requirements_test.txt',
'requirements_test_min.txt') }}" >> $GITHUB_OUTPUT
- name: Restore Python virtual environment
id: cache-venv
uses: actions/cache@v3.0.11
Expand All @@ -49,8 +51,6 @@ jobs:
key: >-
${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{
steps.generate-python-key.outputs.key }}
restore-keys: |
${{ runner.os }}-${{ steps.python.outputs.python-version }}-base-venv-${{ env.CACHE_VERSION }}-
- name: Create Python virtual environment
if: steps.cache-venv.outputs.cache-hit != 'true'
run: |
Expand All @@ -71,8 +71,6 @@ jobs:
path: ${{ env.PRE_COMMIT_CACHE }}
key: >-
${{ runner.os }}-${{ steps.generate-pre-commit-key.outputs.key }}
restore-keys: |
${{ runner.os }}-pre-commit-${{ env.CACHE_VERSION }}-
- name: Install pre-commit dependencies
if: steps.cache-precommit.outputs.cache-hit != 'true'
run: |
Expand All @@ -92,6 +90,7 @@ jobs:
uses: actions/setup-python@v4.3.0
with:
python-version: ${{ env.DEFAULT_PYTHON }}
check-latest: true
- name: Restore Python virtual environment
id: cache-venv
uses: actions/cache@v3.0.11
Expand Down Expand Up @@ -124,6 +123,7 @@ jobs:
run: |
. venv/bin/activate
pip install -e .
pip list | grep 'astroid\|pylint'
pre-commit run --hook-stage manual pylint-with-spelling --all-files

spelling:
Expand All @@ -139,6 +139,7 @@ jobs:
uses: actions/setup-python@v4.3.0
with:
python-version: ${{ env.DEFAULT_PYTHON }}
check-latest: true
- name: Restore Python virtual environment
id: cache-venv
uses: actions/cache@v3.0.11
Expand Down Expand Up @@ -170,6 +171,7 @@ jobs:
uses: actions/setup-python@v4.3.0
with:
python-version: ${{ env.DEFAULT_PYTHON }}
check-latest: true
- name: Restore Python virtual environment
id: cache-venv
uses: actions/cache@v3.0.11
Expand Down
14 changes: 8 additions & 6 deletions .github/workflows/primer-test.yaml
Expand Up @@ -13,7 +13,8 @@ on:
- ".github/workflows/primer-test.yaml"

env:
CACHE_VERSION: 31
CACHE_VERSION: 1
KEY_PREFIX: venv

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
Expand All @@ -40,12 +41,13 @@ jobs:
uses: actions/setup-python@v4.3.0
with:
python-version: ${{ matrix.python-version }}
check-latest: true
- name: Generate partial Python venv restore key
id: generate-python-key
run: >-
echo "key=venv-${{ env.CACHE_VERSION }}-${{
hashFiles('setup.cfg', 'requirements_test.txt', 'requirements_test_min.txt')
}}" >> $GITHUB_OUTPUT
echo "key=${{ env.KEY_PREFIX }}-${{ env.CACHE_VERSION }}-${{
hashFiles('pyproject.toml', 'requirements_test.txt',
'requirements_test_min.txt') }}" >> $GITHUB_OUTPUT
- name: Restore Python virtual environment
id: cache-venv
uses: actions/cache@v3.0.11
Expand All @@ -54,8 +56,6 @@ jobs:
key: >-
${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{
steps.generate-python-key.outputs.key }}
restore-keys: |
${{ runner.os }}-${{ steps.python.outputs.python-version }}-venv-${{ env.CACHE_VERSION }}-
- name: Create Python virtual environment
if: steps.cache-venv.outputs.cache-hit != 'true'
run: |
Expand All @@ -80,6 +80,7 @@ jobs:
uses: actions/setup-python@v4.3.0
with:
python-version: ${{ matrix.python-version }}
check-latest: true
- name: Restore Python virtual environment
id: cache-venv
uses: actions/cache@v3.0.11
Expand Down Expand Up @@ -115,6 +116,7 @@ jobs:
uses: actions/setup-python@v4.3.0
with:
python-version: ${{ matrix.python-version }}
check-latest: true
- name: Restore Python virtual environment
id: cache-venv
uses: actions/cache@v3.0.11
Expand Down
23 changes: 12 additions & 11 deletions .github/workflows/primer_comment.yaml
Expand Up @@ -14,7 +14,9 @@ on:

env:
# This needs to be the SAME as in the Main and PR job
CACHE_VERSION: 31
CACHE_VERSION: 1
KEY_PREFIX: venv-primer
DEFAULT_PYTHON: "3.10"

permissions:
contents: read
Expand All @@ -27,17 +29,18 @@ jobs:
name: Run
runs-on: ubuntu-latest
steps:
- uses: actions/setup-node@v3
- uses: actions/setup-node@v3.5.1
with:
node-version: 16
- run: npm install @octokit/rest
- name: Check out code from GitHub
uses: actions/checkout@v3.1.0
- name: Set up Python 3.10
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
id: python
uses: actions/setup-python@v4.3.0
with:
python-version: "3.10"
python-version: ${{ env.DEFAULT_PYTHON }}
check-latest: true

# Restore cached Python environment
- name: Restore Python virtual environment
Expand All @@ -46,16 +49,16 @@ jobs:
with:
path: venv
key:
${{ runner.os }}-${{ steps.python.outputs.python-version }}-venv-primer-${{
env.CACHE_VERSION }}
${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{
env.KEY_PREFIX }}-${{ env.CACHE_VERSION }}
- name: Fail job if Python cache restore failed
if: steps.cache-venv.outputs.cache-hit != 'true'
run: |
echo "Failed to restore Python venv from cache"
exit 1

- name: Download outputs
uses: actions/github-script@v6
uses: actions/github-script@v6.3.3
with:
script: |
// Download workflow pylint output
Expand Down Expand Up @@ -110,9 +113,8 @@ jobs:
--new-file=output_${{ steps.python.outputs.python-version }}_pr.txt
- name: Post comment
id: post-comment
uses: actions/github-script@v6
uses: actions/github-script@v6.3.3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require('fs')
const comment = fs.readFileSync('tests/.pylint_primer_tests/comment.txt', { encoding: 'utf8' })
Expand All @@ -128,8 +130,7 @@ jobs:
return prNumber
- name: Hide old comments
# Taken from mypy primer
# v0.3.0
uses: kanga333/comment-hider@c12bb20b48aeb8fc098e35967de8d4f8018fffdf
uses: kanga333/comment-hider@c12bb20b48aeb8fc098e35967de8d4f8018fffdf # v0.4.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
leave_visible: 1
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/primer_run_main.yaml
Expand Up @@ -16,7 +16,8 @@ concurrency:

env:
# This needs to be the SAME as in the PR and comment job
CACHE_VERSION: 31
CACHE_VERSION: 1
KEY_PREFIX: venv-primer

permissions:
contents: read
Expand All @@ -37,6 +38,7 @@ jobs:
uses: actions/setup-python@v4.3.0
with:
python-version: ${{ matrix.python-version }}
check-latest: true

- name: Get latest astroid commit
id: get-astroid-sha
Expand All @@ -51,10 +53,8 @@ jobs:
with:
path: venv
key:
${{ runner.os }}-${{ steps.python.outputs.python-version }}-venv-primer-${{
env.CACHE_VERSION }}
restore-keys: |
${{ runner.os }}-${{ steps.python.outputs.python-version }}-venv-primer-${{ env.CACHE_VERSION }}
${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{
env.KEY_PREFIX }}-${{ env.CACHE_VERSION }}
- name: Create Python virtual environment
run: |
python -m venv venv
Expand Down Expand Up @@ -104,6 +104,6 @@ jobs:
uses: actions/upload-artifact@v3.1.1
with:
name: primer_output
path:
path: >-
tests/.pylint_primer_tests/output_${{ steps.python.outputs.python-version
}}_main.txt
12 changes: 7 additions & 5 deletions .github/workflows/primer_run_pr.yaml
Expand Up @@ -25,7 +25,8 @@ concurrency:

env:
# This needs to be the SAME as in the Main and comment job
CACHE_VERSION: 31
CACHE_VERSION: 1
KEY_PREFIX: venv-primer

permissions:
contents: read
Expand All @@ -48,7 +49,8 @@ jobs:
uses: actions/setup-python@v4.3.0
with:
python-version: ${{ matrix.python-version }}
- uses: actions/setup-node@v3
check-latest: true
- uses: actions/setup-node@v3.5.1
with:
node-version: 16
- run: npm install @octokit/rest
Expand All @@ -60,8 +62,8 @@ jobs:
with:
path: venv
key:
${{ runner.os }}-${{ steps.python.outputs.python-version }}-venv-primer-${{
env.CACHE_VERSION }}
${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{
env.KEY_PREFIX }}-${{ env.CACHE_VERSION }}
- name: Fail job if Python cache restore failed
if: steps.cache-venv.outputs.cache-hit != 'true'
run: |
Expand All @@ -71,7 +73,7 @@ jobs:
# Cache primer packages
- name: Download last 'main' run info
id: download-main-run
uses: actions/github-script@v6
uses: actions/github-script@v6.3.3
with:
script: |
// Download 'main' pylint output
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Expand Up @@ -26,6 +26,7 @@ jobs:
uses: actions/setup-python@v4.3.0
with:
python-version: ${{ env.DEFAULT_PYTHON }}
check-latest: true
- name: Install requirements
run: |
# Remove dist, build, and pylint.egg-info
Expand Down