Skip to content

Update reviewer list #330

Update reviewer list

Update reviewer list #330

name: AFIDs Validator CI Workflow
on:
pull_request_target:
types: [opened, reopened, synchronize, ready_for_review, closed]
jobs:
test:
name: Setup environment & test
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10"]
steps:
- name: Checkout pull request branch
uses: actions/checkout@master
with:
ref: ${{ github.sha }}
- name: Select Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Cache environment
uses: actions/cache@v3
id: cache
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ matrix.python-version }}
restore-keys: ${{ runner.os }}-pip-${{ matrix.python-version }}
- name: Install poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}-${{ matrix.python-version }}
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: |
poetry install --no-interaction --no-root
- name: Install library
run: poetry install --no-interaction
- name: Start PostgreSQL services
shell: bash
run: |
sudo systemctl start postgresql.service
pg_isready
- name: Setup PostgreSQL db
shell: bash
env:
psql_db_owner: testuser # PostgreSQL User
psql_db_pw: testpass # PostgreSQL Pass
psql_db_name: testdb # PostgreSQL DB
run: |
sudo -u postgres psql --command="CREATE USER $psql_db_owner PASSWORD '$psql_db_pw'"
sudo -u postgres createdb --owner=$psql_db_owner $psql_db_name
PGPASSWORD=$psql_db_pw psql --username=$psql_db_owner --host=localhost --list $psql_db_name
- name: Test AFIDs validator
shell: bash
env:
FLASK_ENV: testing # Sets flask environment
DATABASE_URL: postgresql://testuser:testpass@localhost/testdb
run: |
poetry run python -m unittest
linting:
name: Lint code
needs: [test]
if: github.event.pull_request.merged == false
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10"]
steps:
- name: Checkout pull request branch
uses: actions/checkout@master
with:
ref: ${{ github.sha }}
- name: Select Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install poetry
uses: snok/install-poetry@v1
with:
version: 1.2.0
virtualenvs-create: true
virtualenvs-in-project: true
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}-${{ matrix.python-version }}
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root --with dev
- name: isort
run: poetry run isort afidsvalidator test -c
- name: black
run: poetry run black afidsvalidator test --check
- name: flake8
run: poetry run flake8 afidsvalidator test
- name: pylint
run: poetry run pylint afidsvalidator test
assign:
name: Reviewer assignment
needs: [linting]
runs-on: ubuntu-latest
if: github.event.pull_request.assignee == null
steps:
- name: Assign reviewer
uses: kentaro-m/[email protected]
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
update_changelog:
name: Update changelog
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true
steps:
- name: Checkout master
uses: actions/checkout@master
with:
ref: refs/heads/master
- name: Draft and update change log
uses: release-drafter/release-drafter@v5
id: release-drafter
with:
commitish: ${{ github.event.pull_request.base.ref }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Get previous release version
run: |
echo "PREV_VER=$(cat pyproject.toml | grep -o -E '(version\s=\s)([[:punct:]])([v][0-9]+\.[0-9]+\.[0-9]+.+)([[:punct:]])' | cut -d ' ' -f 3 | tr -d '"')" >> $GITHUB_ENV
- name: Get previous bump version
env:
PREV_VER: ${{ env.PREV_VER }}
run: |
if [[ "$PREV_VER" != *"-pre."* ]]; then
echo "OLD_BUMP=0" >> $GITHUB_ENV
else
echo "OLD_BUMP=$(echo $PREV_VER | cut -d '.' -f 4)" >> $GITHUB_ENV
fi
- name: Bump version
env:
BUMP_VER: ${{ env.OLD_BUMP }}
run: |
echo "NEW_BUMP=$(($BUMP_VER + 1))" >> $GITHUB_ENV
- name: Set new release version
env:
RD_RELEASE: ${{ steps.release-drafter.outputs.name }}
run: |
if [ ! -z "$RD_RELEASE" ]; then
echo "NEW_RELEASE=$RD_RELEASE" >> $GITHUB_ENV
else
echo "NEW_RELEASE=0.1.0" >> $GITHUB_ENV
fi
- name: Update version in pyproject.toml
uses: jacobtomlinson/gha-find-replace@master
with:
include: "pyproject.toml"
find: 'version = "v(?:([0-9]+\.[0-9]+\.[0-9]+.+)|([0-9]+\.[0-9]+\.[0-9]+))"'
replace: 'version = "${{ env.NEW_RELEASE }}-pre.${{ env.NEW_BUMP }}"'
- name: Commit updates
env:
LATEST_VERSION: ${{ steps.release-drafter.outputs.name }}-pre.${{ env.NEW_BUMP }}
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git diff-index --quiet HEAD || git commit -m "Bump version to $LATEST_VERSION" -a
- name: Push changes
uses: CasperWA/push-protected@v2
with:
branch: ${{ github.event.pull_request.base.ref }}
token: ${{ secrets.BP_PAT_TOKEN }}
unprotect_reviews: True