Merge pull request #8681 from bluetech/ci-permissions
ci: few security/permissions improvements
This commit is contained in:
commit
ff6d29717c
|
@ -13,13 +13,19 @@ on:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
- "[0-9]+.[0-9]+.x"
|
- "[0-9]+.[0-9]+.x"
|
||||||
|
|
||||||
env:
|
env:
|
||||||
PYTEST_ADDOPTS: "--color=yes"
|
PYTEST_ADDOPTS: "--color=yes"
|
||||||
|
|
||||||
|
# Set permissions at the job level.
|
||||||
|
permissions: {}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
timeout-minutes: 30
|
timeout-minutes: 30
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
|
@ -139,10 +145,13 @@ jobs:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
persist-credentials: false
|
||||||
|
|
||||||
- name: Set up Python ${{ matrix.python }}
|
- name: Set up Python ${{ matrix.python }}
|
||||||
uses: actions/setup-python@v2
|
uses: actions/setup-python@v2
|
||||||
with:
|
with:
|
||||||
python-version: ${{ matrix.python }}
|
python-version: ${{ matrix.python }}
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
python -m pip install --upgrade pip
|
python -m pip install --upgrade pip
|
||||||
|
@ -164,19 +173,29 @@ jobs:
|
||||||
|
|
||||||
linting:
|
linting:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
persist-credentials: false
|
||||||
|
|
||||||
- uses: actions/setup-python@v2
|
- uses: actions/setup-python@v2
|
||||||
|
|
||||||
- name: set PY
|
- name: set PY
|
||||||
run: echo "name=PY::$(python -c 'import hashlib, sys;print(hashlib.sha256(sys.version.encode()+sys.executable.encode()).hexdigest())')" >> $GITHUB_ENV
|
run: echo "name=PY::$(python -c 'import hashlib, sys;print(hashlib.sha256(sys.version.encode()+sys.executable.encode()).hexdigest())')" >> $GITHUB_ENV
|
||||||
|
|
||||||
- uses: actions/cache@v2
|
- uses: actions/cache@v2
|
||||||
with:
|
with:
|
||||||
path: ~/.cache/pre-commit
|
path: ~/.cache/pre-commit
|
||||||
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
|
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
python -m pip install --upgrade pip
|
python -m pip install --upgrade pip
|
||||||
pip install tox
|
pip install tox
|
||||||
|
|
||||||
- run: tox -e linting
|
- run: tox -e linting
|
||||||
|
|
||||||
deploy:
|
deploy:
|
||||||
|
@ -184,6 +203,8 @@ jobs:
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
timeout-minutes: 30
|
timeout-minutes: 30
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
needs: [build]
|
needs: [build]
|
||||||
|
|
||||||
|
@ -191,25 +212,31 @@ jobs:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
persist-credentials: false
|
||||||
|
|
||||||
- name: Set up Python
|
- name: Set up Python
|
||||||
uses: actions/setup-python@v2
|
uses: actions/setup-python@v2
|
||||||
with:
|
with:
|
||||||
python-version: "3.7"
|
python-version: "3.7"
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
python -m pip install --upgrade pip
|
python -m pip install --upgrade pip
|
||||||
pip install --upgrade wheel setuptools tox
|
pip install --upgrade wheel setuptools tox
|
||||||
|
|
||||||
- name: Build package
|
- name: Build package
|
||||||
run: |
|
run: |
|
||||||
python setup.py sdist bdist_wheel
|
python setup.py sdist bdist_wheel
|
||||||
|
|
||||||
- name: Publish package to PyPI
|
- name: Publish package to PyPI
|
||||||
uses: pypa/gh-action-pypi-publish@master
|
uses: pypa/gh-action-pypi-publish@master
|
||||||
with:
|
with:
|
||||||
user: __token__
|
user: __token__
|
||||||
password: ${{ secrets.pypi_token }}
|
password: ${{ secrets.pypi_token }}
|
||||||
|
|
||||||
- name: Publish GitHub release notes
|
- name: Publish GitHub release notes
|
||||||
env:
|
env:
|
||||||
GH_RELEASE_NOTES_TOKEN: ${{ secrets.release_notes }}
|
GH_RELEASE_NOTES_TOKEN: ${{ github.token }}
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get install pandoc
|
sudo apt-get install pandoc
|
||||||
tox -e publish-gh-release-notes
|
tox -e publish-gh-release-notes
|
||||||
|
|
|
@ -12,14 +12,21 @@ on:
|
||||||
required: true
|
required: true
|
||||||
default: 'no'
|
default: 'no'
|
||||||
|
|
||||||
|
# Set permissions at the job level.
|
||||||
|
permissions: {}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
pull-requests: write
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
persist-credentials: false
|
||||||
|
|
||||||
- name: Set up Python
|
- name: Set up Python
|
||||||
uses: actions/setup-python@v2
|
uses: actions/setup-python@v2
|
||||||
|
@ -34,9 +41,9 @@ jobs:
|
||||||
- name: Prepare release PR (minor/patch release)
|
- name: Prepare release PR (minor/patch release)
|
||||||
if: github.event.inputs.major == 'no'
|
if: github.event.inputs.major == 'no'
|
||||||
run: |
|
run: |
|
||||||
tox -e prepare-release-pr -- ${{ github.event.inputs.branch }} ${{ secrets.chatops }}
|
tox -e prepare-release-pr -- ${{ github.event.inputs.branch }} ${{ github.token }}
|
||||||
|
|
||||||
- name: Prepare release PR (major release)
|
- name: Prepare release PR (major release)
|
||||||
if: github.event.inputs.major == 'yes'
|
if: github.event.inputs.major == 'yes'
|
||||||
run: |
|
run: |
|
||||||
tox -e prepare-release-pr -- ${{ github.event.inputs.branch }} ${{ secrets.chatops }} --major
|
tox -e prepare-release-pr -- ${{ github.event.inputs.branch }} ${{ github.token }} --major
|
||||||
|
|
|
@ -7,9 +7,15 @@ on:
|
||||||
issue_comment:
|
issue_comment:
|
||||||
types: [created, edited]
|
types: [created, edited]
|
||||||
|
|
||||||
|
# Set permissions at the job level.
|
||||||
|
permissions: {}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
issues: write
|
||||||
|
|
||||||
if: (github.event.comment && startsWith(github.event.comment.body, '@pytestbot please')) || (github.event.issue && !github.event.comment && startsWith(github.event.issue.body, '@pytestbot please'))
|
if: (github.event.comment && startsWith(github.event.comment.body, '@pytestbot please')) || (github.event.issue && !github.event.comment && startsWith(github.event.issue.body, '@pytestbot please'))
|
||||||
|
|
||||||
|
@ -17,15 +23,18 @@ jobs:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
persist-credentials: false
|
||||||
|
|
||||||
- name: Set up Python
|
- name: Set up Python
|
||||||
uses: actions/setup-python@v2
|
uses: actions/setup-python@v2
|
||||||
with:
|
with:
|
||||||
python-version: "3.8"
|
python-version: "3.8"
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
python -m pip install --upgrade pip
|
python -m pip install --upgrade pip
|
||||||
pip install --upgrade setuptools tox
|
pip install --upgrade setuptools tox
|
||||||
|
|
||||||
- name: Prepare release
|
- name: Prepare release
|
||||||
run: |
|
run: |
|
||||||
tox -e release-on-comment -- $GITHUB_EVENT_PATH ${{ secrets.chatops }}
|
tox -e release-on-comment -- $GITHUB_EVENT_PATH ${{ github.token }}
|
||||||
|
|
|
@ -7,22 +7,35 @@ on:
|
||||||
- cron: '0 0 * * 0'
|
- cron: '0 0 * * 0'
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
|
# Set permissions at the job level.
|
||||||
|
permissions: {}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
createPullRequest:
|
createPullRequest:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
pull-requests: write
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Setup Python
|
- name: Setup Python
|
||||||
uses: actions/setup-python@v2
|
uses: actions/setup-python@v2
|
||||||
with:
|
with:
|
||||||
python-version: 3.8
|
python-version: 3.8
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
python -m pip install --upgrade pip
|
python -m pip install --upgrade pip
|
||||||
pip install packaging requests tabulate[widechars]
|
pip install packaging requests tabulate[widechars]
|
||||||
|
|
||||||
- name: Update Plugin List
|
- name: Update Plugin List
|
||||||
run: python scripts/update-plugin-list.py
|
run: python scripts/update-plugin-list.py
|
||||||
|
|
||||||
- name: Create Pull Request
|
- name: Create Pull Request
|
||||||
uses: peter-evans/create-pull-request@2455e1596942c2902952003bbb574afbbe2ab2e6
|
uses: peter-evans/create-pull-request@2455e1596942c2902952003bbb574afbbe2ab2e6
|
||||||
with:
|
with:
|
||||||
|
|
|
@ -9,9 +9,8 @@ The appropriate version will be obtained based on the given branch automatically
|
||||||
|
|
||||||
After that, it will create a release using the `release` tox environment, and push a new PR.
|
After that, it will create a release using the `release` tox environment, and push a new PR.
|
||||||
|
|
||||||
**Secret**: currently the secret is defined in the @pytestbot account,
|
**Token**: currently the token from the GitHub Actions is used, pushed with
|
||||||
which the core maintainers have access to. There we created a new secret named `chatops`
|
`pytest bot <pytestbot@gmail.com>` commit author.
|
||||||
with write access to the repository.
|
|
||||||
"""
|
"""
|
||||||
import argparse
|
import argparse
|
||||||
import re
|
import re
|
||||||
|
|
|
@ -23,8 +23,8 @@ Then the appropriate version will be obtained based on the given branch name:
|
||||||
|
|
||||||
After that, it will create a release using the `release` tox environment, and push a new PR.
|
After that, it will create a release using the `release` tox environment, and push a new PR.
|
||||||
|
|
||||||
**Secret**: currently the secret is defined in the @pytestbot account, which the core maintainers
|
**Token**: currently the token from the GitHub Actions is used, pushed with
|
||||||
have access to. There we created a new secret named `chatops` with write access to the repository.
|
`pytest bot <pytestbot@gmail.com>` commit author.
|
||||||
"""
|
"""
|
||||||
import argparse
|
import argparse
|
||||||
import json
|
import json
|
||||||
|
|
|
@ -1,16 +1,28 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
set -e
|
set -euo pipefail
|
||||||
set -x
|
set -x
|
||||||
|
|
||||||
if [ -z "$TOXENV" ]; then
|
# Install coverage.
|
||||||
|
if [[ -z ${TOXENV+x} || -z $TOXENV ]]; then
|
||||||
python -m pip install coverage
|
python -m pip install coverage
|
||||||
else
|
else
|
||||||
# Add last TOXENV to $PATH.
|
# Add last TOXENV to $PATH.
|
||||||
PATH="$PWD/.tox/${TOXENV##*,}/bin:$PATH"
|
PATH="$PWD/.tox/${TOXENV##*,}/bin:$PATH"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Run coverage.
|
||||||
python -m coverage xml
|
python -m coverage xml
|
||||||
|
|
||||||
|
# Download and verify latest Codecov bash uploader.
|
||||||
# Set --connect-timeout to work around https://github.com/curl/curl/issues/4461
|
# Set --connect-timeout to work around https://github.com/curl/curl/issues/4461
|
||||||
curl -S -L --connect-timeout 5 --retry 6 -s https://codecov.io/bash -o codecov-upload.sh
|
curl --silent --show-error --location --connect-timeout 5 --retry 6 -o codecov https://codecov.io/bash
|
||||||
bash codecov-upload.sh -Z -X fix -f coverage.xml "$@"
|
VERSION=$(grep --only-matching 'VERSION=\"[0-9\.]*\"' codecov | cut -d'"' -f2)
|
||||||
|
if command -v sha256sum; then
|
||||||
|
sha256sum --check --strict --ignore-missing --quiet <(curl --silent "https://raw.githubusercontent.com/codecov/codecov-bash/${VERSION}/SHA256SUM")
|
||||||
|
else
|
||||||
|
shasum --algorithm 256 --check --strict --ignore-missing --quiet <(curl --silent "https://raw.githubusercontent.com/codecov/codecov-bash/${VERSION}/SHA256SUM")
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Upload coverage.
|
||||||
|
bash codecov -Z -X fix -f coverage.xml "$@"
|
||||||
|
|
Loading…
Reference in New Issue