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

Release automation #117

Merged
merged 9 commits into from
Jul 26, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ ignore = E203,E501,W503
classmethod-decorators =
classmethod
validator
per-file-ignores =
*/__init__.py: F401
65 changes: 23 additions & 42 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
# yamllint disable rule:line-length
name: Lint Code Base

on:
pull_request:
push:
branches-ignore: [master, main]
on: # yamllint disable-line rule:truthy rule:comments
# allow this workflow to be called from other workflows
workflow_call:

jobs:
lint:
Expand All @@ -18,56 +17,38 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v3
if: ${{ !env.ACT }} # skip during local actions testing
with:
fetch-depth: 0
- name: Fetch git base ref
run: |
git fetch --depth=1 \
origin +${{ github.base_ref || github.event.repository.default_branch }}

- name: Get npm cache directory
id: npm-cache-dir
run: echo "dir=$(npm config get cache)" >> $GITHUB_OUTPUT

- name: npm cache
uses: actions/cache@v3
with:
path: ${{ steps.npm-cache-dir.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('.github/workflows/linter.yml') }}
restore-keys: |
${{ runner.os }}-node-

- name: Install node tools
run: npm i --silent -g markdownlint-cli@0.31.1

- uses: mfinelli/setup-shfmt@v2
with:
shfmt-version: 3.5.0

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: |
pyproject.toml
cache-dependency-path: pyproject.toml

- name: Install pip deps
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install .[lint]

- name: pre-commit cache
uses: actions/cache@v3
with:
path: ~/.cache/pre-commit
key: pre-commit-${{ env.pythonLocation }}-${{ hashFiles('.pre-commit-config.yaml') }}
restore-keys: |
pre-commit-${{ env.pythonLocation }}-
- name: Autoflake
run: autoflake -c -r yascheduler

- name: Black
run: black --check --diff yascheduler

- name: Run pre-commit
- name: isort
run: isort -c --diff **/*.py

- name: flake8
run: |
git branch
pre-commit run --show-diff-on-failure --color=always \
--from-ref ${{ format('remotes/origin/{0}', github.base_ref || github.event.repository.default_branch) }} \
--to-ref ${{ github.sha }}
flake8 yascheduler

- name: pylint
# only errors now
run: pylint -E yascheduler

- name: pyupgrade
run: pyupgrade --py38-plus --keep-percent-format
35 changes: 35 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
# yamllint disable rule:line-length
name: PR action

on:
pull_request:
types: [opened, reopened, synchronize]

jobs:
lint:
uses: ./.github/workflows/linter.yml

build:
name: Build
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3
if: ${{ !env.ACT }} # skip during local actions testing

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.11
cache: pip
cache-dependency-path: pyproject.toml

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install .[release]

- name: Build
run: flit build
71 changes: 71 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
---
# yamllint disable rule:line-length
name: Push action

on:
push:
branches:
- master

jobs:
release:
name: Bump version and create draft release
runs-on: ubuntu-latest
permissions:
contents: write
concurrency:
group: release

steps:
- name: Checkout repository
uses: actions/checkout@v3
if: ${{ !env.ACT }} # skip during local actions testing
with:
fetch-depth: 0

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.11
cache: pip
cache-dependency-path: pyproject.toml

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install .[release]

- name: Create bump and changelog
id: cz
if: github.repository == 'tilde-lab/yascheduler'
uses: commitizen-tools/commitizen-action@e41bf7f2029bc8175af362badd6fd0860a329b0f
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
changelog_increment_filename: .CHANGELOG-CURRENT.md
push: true
commit: true

- name: Print new version
if: github.repository == 'tilde-lab/yascheduler'
run: echo "Bumped to version ${{ steps.cz.outputs.version }}"

- name: Build
run: flit build

- name: Stop if no bump
id: no-bump
continue-on-error: true
# will fail if not on exact tag
run: git describe --tags --exact-match

- name: Create Release Draft
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844
if: steps.no-bump.outcome == 'success'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
draft: true
tag_name: v${{ steps.cz.outputs.version }}
body_path: .CHANGELOG-CURRENT.md
fail_on_unmatched_files: true
files: dist/*
42 changes: 42 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
# yamllint disable rule:line-length
name: Publish release to pypi

on:
release:
types: [published]

workflow_dispatch:

jobs:
pypi:
runs-on: ubuntu-latest
concurrency:
group: release

steps:
- name: Checkout repository
uses: actions/checkout@v3
if: ${{ !env.ACT }} # skip during local actions testing
with:
fetch-depth: 0

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.11
cache: pip
cache-dependency-path: pyproject.toml

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install .[release]

- name: Build
run: flit build

- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
107 changes: 48 additions & 59 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,42 +17,6 @@ repos:
- id: mixed-line-ending
- id: trailing-whitespace

- repo: https://github.com/myint/autoflake
rev: v1.4
hooks:
- id: autoflake
args:
- --expand-star-imports
- --ignore-init-module-imports
- --in-place
- --remove-all-unused-imports
- --remove-duplicate-keys
- --remove-unused-variables

- repo: https://github.com/psf/black
rev: 21.12b0
hooks:
- id: black
entry: black
args:
- --target-version
- py37
additional_dependencies: ["click<8.1.0"]

- repo: https://github.com/pycqa/flake8
rev: 4.0.1
hooks:
- id: flake8
name: flake8
exclude: /__init__\.py$
additional_dependencies: ["flake8-bugbear==22.4.25"]

- repo: https://github.com/timothycrosley/isort
rev: 5.11.5
hooks:
- id: isort
args: [--settings, .]

- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.31.1
hooks:
Expand All @@ -63,14 +27,6 @@ repos:
hooks:
- id: prettier

- repo: https://github.com/asottile/pyupgrade
rev: v2.37.3
hooks:
- id: pyupgrade
args:
- --py37-plus
- --keep-percent-format

- repo: https://github.com/adrienverge/yamllint
rev: v1.26.3
hooks:
Expand All @@ -87,18 +43,51 @@ repos:
- --simplify
- --list

# TODO:
# - repo: local
# hooks:
# - id: pylint
# name: pylint
# entry: pylint
# language: system
# types: [python]
# require_serial: true
# args:
# - --rcfile=.pylintrc
# TODO: cpp
# TODO: clang format
# TODO: gitleaks
# TODO: mypy
- repo: local
hooks:
- id: autoflake
name: autoflake
entry: autoflake
language: system
types: [python]
args:
- --in-place

- id: black
name: black
entry: black
language: system
types: [python]

- id: flake8
name: flake8
entry: flake8
language: system
types: [python]
args:
- yascheduler

- id: isort
name: isort
entry: isort
language: system
types: [python]

- id: pylint-errors
name: pylint only errors
entry: pylint
language: system
types: [python]
require_serial: true
args:
- -E
- yascheduler

- id: pyupgrade
name: pyupgrade
entry: pyupgrade
language: system
types: [python]
args:
- --py38-plus
- --keep-percent-format
Empty file added CHANGELOG.md
Empty file.
7 changes: 7 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright © 2019-2023 Tilde Materials Informatics

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ build-backend = "flit_core.buildapi"

[project]
name = "yascheduler"
version = "1.0.11"
version = "1.0.12"
description = """Yet another computing scheduler and cloud orchestration engine"""
authors = [
{name = "Evgeny Blokhin", email = "eb@tilde.pro"},
Expand Down Expand Up @@ -54,7 +54,6 @@ lint = [
"flake8",
"flake8-bugbear",
"isort",
"pre-commit",
"pylint",
"pylint-per-file-ignores >= 1",
"pyupgrade",
Expand Down
Loading