Skip to content

Commit

Permalink
Lint YAML files with yamllint
Browse files Browse the repository at this point in the history
There is now a configuration file for `yamllint`
and a `pre-commit` hook.

The most straightforward linting issues were fixed.
The other ones are ignored and should be handled in the future.
  • Loading branch information
fabcor-maxiv committed Jun 26, 2024
1 parent 092639d commit 7e60cfd
Show file tree
Hide file tree
Showing 15 changed files with 180 additions and 128 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
---

name: Python build and test

on: [push, pull_request]
"on": [push, pull_request]

jobs:
build-linux:
runs-on: ubuntu-latest
strategy:
max-parallel: 5
matrix:
python-version: ["3.10"] #, "3.9", "3.10"]
python-version: ["3.10"]

# Skip `pull_request` runs on local PRs for which `push` runs are already triggered
# yamllint disable-line rule:line-length
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository

# Service containers to run with `container-job`
Expand Down
168 changes: 86 additions & 82 deletions .github/workflows/bump_version_and_tag.yml
Original file line number Diff line number Diff line change
@@ -1,94 +1,98 @@
---

# yamllint disable rule:line-length

name: Create/Update Tag
on:
"on":
push:
branches:
- develop
jobs:
create-version-tag:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
token: ${{ secrets.CI_TOKEN }}
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Update version
id: update-version
run: |
- uses: actions/checkout@v3
with:
token: ${{ secrets.CI_TOKEN }}
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Update version
id: update-version
run: |
pip install --upgrade pip
pip install poetry
poetry version minor
git config --global user.email "[email protected]"
git config --global user.name "Marcus Oskarsson"
git add -A
git commit -m "[skip ci] Bumped minor version"
git push -f
poetry build
- name: Publish package to PyPI
id: publish-pacakge
run: |
poetry config pypi-token.pypi ${{ secrets.PYPI }}
poetry publish
- name: Read package version
id: set-tag
run: |
pip install --upgrade pip
pip install poetry
poetry version minor
git config --global user.email "[email protected]"
git config --global user.name "Marcus Oskarsson"
git add -A
git commit -m "[skip ci] Bumped minor version"
git push -f
poetry build
- name: Publish package to PyPI
id: publish-pacakge
run: |
poetry config pypi-token.pypi ${{ secrets.PYPI }}
poetry publish
- name: Read package version
id: set-tag
run: |
pip install --upgrade pip
pip install toml
echo ::set-output name=tag_name::v$(python -c 'import toml; print(toml.load("./pyproject.toml")["tool"]["poetry"]["version"])')
- name: Check tag exists
id: check-tag-exists
uses: actions/github-script@v6
env:
TAG: ${{ steps.set-tag.outputs.tag_name }}
with:
github-token: ${{ github.token }}
script: |
// https://github.com/mukunku/tag-exists-action
var exists = 'false';
try {
const getRefResponse = await github.rest.git.getRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: "refs/tags/${{ steps.set-tag.outputs.tag_name }}"
});
pip install toml
echo ::set-output name=tag_name::v$(python -c 'import toml; print(toml.load("./pyproject.toml")["tool"]["poetry"]["version"])')
- name: Check tag exists
id: check-tag-exists
uses: actions/github-script@v6
env:
TAG: ${{ steps.set-tag.outputs.tag_name }}
with:
github-token: ${{ github.token }}
script: |
// https://github.com/mukunku/tag-exists-action
var exists = 'false';
try {
const getRefResponse = await github.rest.git.getRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: "refs/tags/${{ steps.set-tag.outputs.tag_name }}"
});
if (getRefResponse.status === 200) {
console.log("Tag was found");
exists = 'true';
}
} catch(error) {
console.log("Tag was not found");
}
core.setOutput('exists', exists);
if (getRefResponse.status === 200) {
console.log("Tag was found");
exists = 'true';
}
} catch(error) {
console.log("Tag was not found");
}
core.setOutput('exists', exists);
- name: Update tag
uses: actions/github-script@v6
if: steps.check-tag-exists.outputs.exists == 'true'
env:
TAG: ${{ steps.set-tag.outputs.tag_name }}
with:
github-token: ${{ github.token }}
script: |
github.rest.git.updateRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: "refs/tags/${{ steps.set-tag.outputs.tag_name }}",
sha: context.sha
})
- name: Update tag
uses: actions/github-script@v6
if: steps.check-tag-exists.outputs.exists == 'true'
env:
TAG: ${{ steps.set-tag.outputs.tag_name }}
with:
github-token: ${{ github.token }}
script: |
github.rest.git.updateRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: "refs/tags/${{ steps.set-tag.outputs.tag_name }}",
sha: context.sha
})
- name: Create tag
uses: actions/github-script@v6
if: steps.check-tag-exists.outputs.exists != 'true'
env:
TAG: ${{ steps.set-tag.outputs.tag_name }}
with:
github-token: ${{ github.token }}
script: |
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: "refs/tags/${{ steps.set-tag.outputs.tag_name }}",
sha: context.sha
})
- name: Create tag
uses: actions/github-script@v6
if: steps.check-tag-exists.outputs.exists != 'true'
env:
TAG: ${{ steps.set-tag.outputs.tag_name }}
with:
github-token: ${{ github.token }}
script: |
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: "refs/tags/${{ steps.set-tag.outputs.tag_name }}",
sha: context.sha
})
2 changes: 1 addition & 1 deletion .github/workflows/pages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ name: "Pages"
concurrency:
group: "pages"

on:
"on":
pull_request:
push:

Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/ui.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
---

# yamllint disable rule:line-length

name: UI

on: [push, pull_request]
"on": [push, pull_request]

jobs:
format:
Expand Down
36 changes: 21 additions & 15 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
---

default_language_version:
python: python3.10


repos:

- repo: https://github.com/adrienverge/yamllint
rev: v1.35.1
hooks:
- id: yamllint
args:
- --strict

- repo: https://github.com/python-poetry/poetry
rev: 1.5.0
hooks:
- id: poetry-check
# - id: poetry-lock

- repo: https://github.com/myint/autoflake
rev: v1.6.0
hooks:
Expand All @@ -17,11 +29,13 @@ repos:
- --in-place
- --remove-duplicate-keys
- --ignore-pass-after-docstring

- repo: https://github.com/psf/black
rev: 22.8.0
hooks:
- id: black
name: Black
- id: black
name: Black

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
Expand All @@ -37,18 +51,10 @@ repos:
exclude: ^.drone\.yml|meta.yaml
- id: mixed-line-ending
args: ["--fix=lf"]
# - repo: https://github.com/PyCQA/isort
# rev: 5.10.1
# hooks:
# - id: isort
# name: Import Sort
# args:
# - --settings=.

- repo: https://github.com/PyCQA/flake8
rev: 4.0.1
hooks:
- id: flake8
name: Flake8
# Not using bugbear for now
# additional_dependencies: ["flake8-bugbear==22.9.11"]
exclude: (ui/|test/)
- id: flake8
name: Flake8
exclude: (ui/|test/)
1 change: 1 addition & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ build:
- "git fetch --unshallow || true"
- "mamba env create --file conda-environment.yml --force"
- "mamba run --name mxcubeweb poetry install --only=docs,main"
# yamllint disable-line rule:line-length
- "(mamba run --name mxcubeweb redis-server &) && mamba run --name mxcubeweb python -m sphinx -T -E -b html -d _build/doctrees -c docs docs/source ${READTHEDOCS_OUTPUT}/html && mamba run --name mxcubeweb redis-cli shutdown"


Expand Down
11 changes: 11 additions & 0 deletions .yamllint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---

extends: default

ignore: |
ui/pnpm-lock.yaml
rules:
# Match line length to the one set by `black` the Python formatter
line-length:
max: 88
2 changes: 2 additions & 0 deletions conda-environment.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
---

name: mxcubeweb

channels:
Expand Down
19 changes: 10 additions & 9 deletions meta.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{% set data = load_setup_py_data(setup_file="./setup.py",
from_recipe_dir=True) %}
---

# {% set data = load_setup_py_data(setup_file="./setup.py", from_recipe_dir=True) %}

package:
name: {{ data.get('name') }}
version: {{ data.get('version') }}
name: {{data.get('name')}}
version: {{data.get('version')}}

source:
path: .
Expand Down Expand Up @@ -51,8 +52,8 @@ test:
- {{data.get('name')}}

about:
home: {{ data.get('url')}}
license: {{ data.get('license')}}
summary: {{ data.get('description')}}
author: {{ data.get('author')}}
description: {{ data.get('description')}}
home: {{data.get('url')}}
license: {{data.get('license')}}
summary: {{data.get('description')}}
author: {{data.get('author')}}
description: {{data.get('description')}}
Loading

0 comments on commit 7e60cfd

Please sign in to comment.