Skip to content

Commit

Permalink
pre-commit: introduce pre-commit and fix linters
Browse files Browse the repository at this point in the history
  • Loading branch information
schuellerf committed Jul 15, 2024
1 parent 8ab8746 commit 6320416
Show file tree
Hide file tree
Showing 41 changed files with 276 additions and 118 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
"golang.Go",
"GitHub.vscode-pull-request-github"
]
}
}
1 change: 1 addition & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Basic test trying dependabot
---

version: 2
updates:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/auto-merge-dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
---
# Taken from https://docs.github.com/en/code-security/dependabot/working-with-dependabot/automating-dependabot-with-github-actions#common-dependabot-automations

name: Dependabot auto-approve and auto-merge
on: pull_request_target
on: pull_request_target # yamllint disable-line rule:truthy

permissions: write-all

Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/create-tag.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
---
# This action creates a release every Monday at 5:00 UTC.
name: "Create and push release tag"

on:
on: # yamllint disable-line rule:truthy
workflow_dispatch:
schedule:
- cron: "0 5 * * 1"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/gitlab-helper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
---
name: GitLab

on:
on: # yamllint disable-line rule:truthy
pull_request:
branches:
- "*"
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/pr_best_practices.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
---
name: "Verify PR best practices"

on:
on: # yamllint disable-line rule:truthy
pull_request_target:
branches: [ main ]
branches: [main]

jobs:
pr-best-practices:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
name: "Create GitHub release"

on:
on: # yamllint disable-line rule:truthy
push:
tags:
- "v*"
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/stale-cleanup.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
name: Mark and close stale issues and PRs

on:
on: # yamllint disable-line rule:truthy
schedule:
- cron: '0 4 * * *'

Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/test-osbuild-composer-intergation.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
name: "[integration]"

on:
on: # yamllint disable-line rule:truthy
pull_request:
branches:
- "*"
Expand All @@ -13,9 +14,9 @@ jobs:
image: registry.fedoraproject.org/fedora:latest

steps:
# krb5-devel is needed to test internal/upload/koji package
# gcc is needed to build the mock depsolver binary for the unit tests
# gpgme-devel is needed for container upload dependencies
# krb5-devel is needed to test internal/upload/koji package
# gcc is needed to build the mock depsolver binary for the unit tests
# gpgme-devel is needed for container upload dependencies
- name: Install build and test dependencies
run: dnf -y install krb5-devel gcc git-core go gpgme-devel osbuild-depsolve-dnf btrfs-progs-devel device-mapper-devel

Expand Down
61 changes: 31 additions & 30 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
---
name: Tests

# NOTE(mhayden): Restricting branches prevents jobs from being doubled since
# a push to a pull request triggers two events.
on:
on: # yamllint disable-line rule:truthy
pull_request:
branches:
- "*"
Expand Down Expand Up @@ -78,28 +79,28 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Set up Go 1.21
uses: actions/setup-go@v5
with:
go-version: "1.21"
id: go
- name: Set up Go 1.21
uses: actions/setup-go@v5
with:
go-version: "1.21"
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Check out code into the Go module directory
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Apt update
run: sudo apt update
- name: Apt update
run: sudo apt update

# This is needed for the container resolver dependencies
- name: Install libgpgme devel package
run: sudo apt install -y libgpgme-dev libbtrfs-dev libdevmapper-dev podman
# This is needed for the container resolver dependencies
- name: Install libgpgme devel package
run: sudo apt install -y libgpgme-dev libbtrfs-dev libdevmapper-dev podman

# We need to run the test as root, since we use the root
# containers-storage for the local resolvers
- name: Run unit tests
run: sudo go test -v ./pkg/container/... --force-local-resolver
# We need to run the test as root, since we use the root
# containers-storage for the local resolvers
- name: Run unit tests
run: sudo go test -v ./pkg/container/... --force-local-resolver

unit-tests-c9s:
name: "🛃 Unit tests (CentOS Stream 9)"
Expand Down Expand Up @@ -172,17 +173,17 @@ jobs:
name: "🐚 Shellcheck"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Run ShellCheck
uses: ludeeus/action-shellcheck@00cae500b08a931fb5698e11e79bfbd38e612a38
with:
ignore: vendor # We don't want to fix the code in vendored dependencies
env:
# don't check /etc/os-release sourcing, allow useless cats to live inside our codebase, and
# allow seemingly unreachable commands
SHELLCHECK_OPTS: -e SC1091 -e SC2002 -e SC2317
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Run ShellCheck
uses: ludeeus/action-shellcheck@00cae500b08a931fb5698e11e79bfbd38e612a38
with:
ignore: vendor # We don't want to fix the code in vendored dependencies
env:
# don't check /etc/os-release sourcing, allow useless cats to live inside our codebase, and
# allow seemingly unreachable commands
SHELLCHECK_OPTS: -e SC1091 -e SC2002 -e SC2317

python-test:
name: "🐍 pytest (imgtestlib)"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/trigger-gitlab.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
---
name: Start GitLab CI

on:
on: # yamllint disable-line rule:truthy
workflow_run:
workflows: ["GitLab"]
types: [completed]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update-bootc-image-builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
---
name: "Update bootc-image-builder ref"

on:
on: # yamllint disable-line rule:truthy
workflow_dispatch:
# temporarily disabled until we fix the compatibility between bib and our bootc containers
# schedule:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ __pycache__
/rpmbuild
/test/data/manifests
/tools/appsre-ansible/inventory
dictionary.dic

*~
71 changes: 36 additions & 35 deletions .packit.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# https://packit.dev/docs/configuration/
---

specfile_path: osbuild-composer.spec

Expand All @@ -12,40 +13,40 @@ upstream_tag_template: v{version}

srpm_build_deps: []
actions:
get-current-version: bash -c "git describe --tags --abbrev=0 | sed 's|v||'"
post-upstream-clone: "./tools/rpm_spec_add_provides_bundle.sh"
get-current-version: bash -c "git describe --tags --abbrev=0 | sed 's|v||'"
post-upstream-clone: "./tools/rpm_spec_add_provides_bundle.sh"

jobs:
- job: bodhi_update
trigger: commit
dist_git_branches:
- fedora-branched # rawhide updates are created automatically
- job: koji_build
trigger: commit
dist_git_branches:
- fedora-all
- job: propose_downstream
trigger: release
dist_git_branches:
- fedora-all
- job: copr_build
trigger: pull_request
targets: &build_targets
- centos-stream-8-aarch64
- centos-stream-8-x86_64
- centos-stream-9-aarch64
- centos-stream-9-x86_64
- fedora-all-aarch64
- fedora-all-s390x
- fedora-all-ppc64le
- fedora-all
- rhel-8-aarch64
- rhel-8-x86_64
- rhel-9-aarch64
- rhel-9-x86_64
- job: copr_build
trigger: commit
branch: main
owner: "@osbuild" # copr repo namespace
project: osbuild-composer # copr repo name so you can consume the builds
targets: *build_targets
- job: bodhi_update
trigger: commit
dist_git_branches:
- fedora-branched # rawhide updates are created automatically
- job: koji_build
trigger: commit
dist_git_branches:
- fedora-all
- job: propose_downstream
trigger: release
dist_git_branches:
- fedora-all
- job: copr_build
trigger: pull_request
targets: &build_targets
- centos-stream-8-aarch64
- centos-stream-8-x86_64
- centos-stream-9-aarch64
- centos-stream-9-x86_64
- fedora-all-aarch64
- fedora-all-s390x
- fedora-all-ppc64le
- fedora-all
- rhel-8-aarch64
- rhel-8-x86_64
- rhel-9-aarch64
- rhel-9-x86_64
- job: copr_build
trigger: commit
branch: main
owner: "@osbuild" # copr repo namespace
project: osbuild-composer # copr repo name so you can consume the builds
targets: *build_targets
30 changes: 30 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
---

exclude: "vendor/.*"
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- repo: https://github.com/adrienverge/yamllint
rev: v1.35.1
hooks:
- id: yamllint
- repo: https://github.com/schuellerf/pre-commit-pyspelling
rev: 0.1.0
hooks:
- id: pyspelling
args: ["--config", ".spellcheck.yml"]
- repo: https://github.com/hhatto/autopep8
rev: v2.3.0
hooks:
- id: autopep8
- repo: https://github.com/golangci/golangci-lint
rev: v1.59.1
hooks:
- id: golangci-lint
Loading

0 comments on commit 6320416

Please sign in to comment.