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

ci: Make badges consistent, run markdownlint all .md files #42

Merged
merged 5 commits into from
Aug 24, 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
8 changes: 8 additions & 0 deletions inventory/group_vars/active_roles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,20 @@ present_templates:
- .github/workflows/pr-title-lint.yml
- .github/workflows/test_converting_readme.yml
- .github/workflows/weekly_ci.yml
- .github/workflows/woke.yml
- README-ansible.md
absent_files:
- .github/workflows/commitlint.yml
- .github/workflows/tox.yml
- README-devel.md
- README-testing.md
- .github/actions/custom-woke-action/LICENSE
- .github/actions/custom-woke-action/README.md
- .github/actions/custom-woke-action/action.yml
- .github/actions/custom-woke-action/entrypoint.sh
- .github/actions/custom-woke-action/testdata/bad.txt
- .github/actions/custom-woke-action
- .github/actions
github_org: linux-system-roles
github_url_prefix: "https://github.com/"
default_ansible_lint:
Expand Down
1 change: 1 addition & 0 deletions inventory/host_vars/metrics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ ansible_lint:
- performancecopilot.metrics.redis
- performancecopilot.metrics.repository
- performancecopilot.metrics.spark
markdownlint_args: "--ignore=vendor"
4 changes: 4 additions & 0 deletions inventory/host_vars/network.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@ yamllint:
ignore: |
tests/roles/
role_specific_contributing: include_files/network_contributing.md
present_badges:
- "[![Coverage Status](https://coveralls.io/repos/github/linux-system-roles/network/badge.svg)](https://coveralls.io/github/linux-system-roles/network)"
- "[![Code Style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)"
- "[![Language grade: Python](https://img.shields.io/lgtm/grade/python/g/linux-system-roles/network.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/linux-system-roles/network/context:python)"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok - but note that lgtm.com is deprecated and will be removed at some point https://github.blog/2022-08-15-the-next-step-for-lgtm-com-github-code-scanning/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just used what's in the network role already. We can revisit it later.

9 changes: 4 additions & 5 deletions playbooks/include_files/kernel_settings_contributing.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@

Testing kernel_settings modules
-------------------------------
## Testing kernel_settings modules

It is recommended to use `tox` to set up your `virtualenv` for
development/testing purposes:

```
```bash
dnf/yum install python-tox
tox -e py38
```

You can also use the virtualenv created by `tox` just like any
other virtualenv created by `python-virtualenv`:

```
```bash
. .tox/env-py38/bin/activate
python
>>> import package.that.only.exists.in.venv
Expand All @@ -31,7 +30,7 @@ run and debug unit tests. However, you may need to create a `.env` file like
this, in order for code navigation, auto-completion, and test discovery to
work correctly:

```
```bash
PYTHONPATH=/full/path/to/tuned:/full/path/to/linux-system-roles/kernel_settings/library
```

Expand Down
3 changes: 1 addition & 2 deletions playbooks/include_files/network_contributing.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

Debugging network system role
-----------------------------
## Debugging network system role

When using the `nm` provider, NetworkManager create a checkpoint and reverts the
changes on failures. This makes it hard to debug the error. To disable this, set
Expand Down
3 changes: 1 addition & 2 deletions playbooks/include_files/ssh_contributing.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

Developer documentation for ssh system role
-------------------------------------------
## Developer documentation for ssh system role

### Internal role variables

Expand Down
3 changes: 1 addition & 2 deletions playbooks/include_files/storage_contributing.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

Storage system role architecture
--------------------------------
## Storage system role architecture

### Overview

Expand Down
9 changes: 7 additions & 2 deletions playbooks/templates/.github/workflows/markdownlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,13 @@ jobs:
- name: Check out code
uses: {{ gha_checkout_action }}

- name: Lint README.md
# CHANGELOG.md is generated automatically from PR titles and descriptions
# It might have issues but they are not critical
- name: Lint all markdown files except for CHANGELOG.md
uses: docker://avtodev/markdown-lint:master
with:
args: README.md
args: >-
{{ markdownlint_args | d() -}}
--ignore=CHANGELOG.md
**/*.md
config: .markdownlint.yaml
19 changes: 19 additions & 0 deletions playbooks/templates/.github/workflows/woke.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# yamllint disable rule:line-length
name: Woke
on: # yamllint disable-line rule:truthy
- pull_request
jobs:
woke:
name: Detect non-inclusive language
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: {{ gha_checkout_action }}

- name: Run lsr-woke-action
# Originally, uses: get-woke/woke-action@v0
uses: linux-system-roles/lsr-woke-action@main
with:
woke-args: "-c https://raw.githubusercontent.com/linux-system-roles/tox-lsr/main/src/tox_lsr/config_files/woke.yml --count-only-error-for-failure"
# Cause the check to fail on any broke rules
fail-on-error: true
3 changes: 1 addition & 2 deletions playbooks/templates/README-ansible.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
Introduction to Ansible for Linux System Roles
==============================================
# Introduction to Ansible for Linux System Roles

If you are not familiar with Ansible, please see
[Introduction to Ansible for Linux System Roles](https://linux-system-roles.github.io/documentation/intro-to-ansible-for-system-roles.html),
Expand Down
10 changes: 4 additions & 6 deletions playbooks/templates/contributing.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
{% set title = "Contributing to the " ~ inventory_hostname ~ " Linux System Role" %}
{% set title = "# Contributing to the " ~ inventory_hostname ~ " Linux System Role" %}
{{ title }}
{{ "=" * (title | length) }}

Where to start
--------------
## Where to start

The first place to go is [Contribute](https://linux-system-roles.github.io/contribute.html).
This has all of the common information that all role developers need:
Expand All @@ -22,9 +20,9 @@ are likely to be suitable for new contributors!

**Code** is managed on [Github](https://github.com/linux-system-roles/{{ inventory_hostname }}), using
[Pull Requests](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/about-pull-requests).

{% if 'python_roles' in group_names %}
### Python Code

## Python Code

The Python code needs to be **compatible with the Python versions supported by
the role platform**.
Expand Down
32 changes: 32 additions & 0 deletions playbooks/update_files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,37 @@
__present_python_templates + __present_shellcheck_templates)) +
([__role_template_dir] | product(__role_present_templates)) }}"

- name: Find workflows to create badges for
find:
paths: "{{ git_dir }}/.github/workflows"
file_type: file
excludes:
- ansible-managed-var-comment.yml
- ansible-plugin-scan.yml
- build_docs.yml
- changelog_to_tag.yml
- pr-title-lint.yml
- test_converting_readme.yml
- weekly_ci.yml
register: find

- name: Ensure badges in README.md
lineinfile:
path: "{{ git_dir }}/README.md"
regex: \[\!.*
firstmatch: true
line: "{%-for file in find.files -%}\
[![{{ file.path | basename }}]\
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This means the badge will have the filename instead of a "user friendly" name?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, GitHub renders this fine to the name of the workflow, and it's easier to get the filename than to read it's name from a file.

(https://github.com/linux-system-roles/{{ inventory_hostname }}/actions/workflows/{{ file.path | basename }}/badge.svg)]\
(https://github.com/linux-system-roles/{{ inventory_hostname }}/actions/workflows/{{ file.path | basename }})\
{{- ' ' if not loop.last else '' -}}\
{% endfor %}
{{- ' ' if present_badges | d([]) | length > 0 else '' -}}\
{%- for badge in present_badges | d([]) -%}
{{ badge }}\
{{ ' ' if not loop.last else '' }}\
{% endfor %}"

- name: Create git commit, PR
changed_when: false
shell:
Expand All @@ -155,6 +186,7 @@
for file in {{ __all_present | join(" ") }}; do
git add "$file"
done
git add README.md
for file in {{ __all_absent | join(" ") }}; do
if [ ! -f "$file" ]; then
echo WARNING: file to be deleted was not found: "$file"
Expand Down