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 Improvements #11

Merged
merged 2 commits into from
Nov 3, 2024
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
17 changes: 9 additions & 8 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
---
version: 2
updates:
# Check for updated Rust packages
- package-ecosystem: "cargo"
directory: "/"
schedule:
interval: "weekly"
- package-ecosystem: cargo
directory: /
schedule:
interval: weekly
# Check for updated GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
41 changes: 41 additions & 0 deletions .github/generate_matrix.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env python3
# Copyright (c) 2024 Jan Holthuis <[email protected]>
#
# This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
# the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# SPDX-License-Identifier: MPL-2.0

import argparse
import tomllib
import json
import itertools


def generate_matrix(features: list[str]):
for i in range(len(features) + 1):
yield from itertools.combinations(iter(features), i)


def main(argv=None):
parser = argparse.ArgumentParser()
parser.add_argument("cargo_file", type=argparse.FileType("rb"))
parser.add_argument("output_file", type=argparse.FileType("w"))
args = parser.parse_args(argv)

cargo_toml = tomllib.load(args.cargo_file)
features = [
feature for feature in cargo_toml["features"].keys() if feature != "default"
]
matrix = {
"include": [
{"features": "{}".format(",".join(f))}
for f in generate_matrix(features=features)
]
}

args.output_file.write("matrix={}".format(json.dumps(matrix)))


if __name__ == "__main__":
main()
45 changes: 33 additions & 12 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,37 @@
---
name: Build
on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Print Rust version
run: rustc -vV
- name: Run tests
run: cargo test --all-features --verbose
- name: Run bench
run: cargo bench --all-features --verbose
- name: Run doc
run: cargo doc --all-features --verbose
generate-matrix:
name: Generate Build Matrix
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.13'
- name: Generate Build Matrix
id: set-matrix
run: python .github/generate_matrix.py Cargo.toml "$GITHUB_OUTPUT"

build:
needs: generate-matrix
runs-on: ubuntu-latest
strategy:
matrix: ${{ fromJson(needs.generate-matrix.outputs.matrix) }}
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Print Rust version
run: rustc -vV
- name: Run tests
run: cargo test --no-default-features --features "${{ matrix.features }}" --verbose
- name: Run bench
run: cargo bench --no-default-features --features "${{ matrix.features }}" --verbose
- name: Run doc
run: cargo doc --no-default-features --features "${{ matrix.features }}" --verbose
19 changes: 10 additions & 9 deletions .github/workflows/dependabot-auto-merge.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
---
name: Auto-merge Dependabot PR

on:
pull_request:
pull_request:

jobs:
auto-merge:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ahmadnassri/action-dependabot-auto-merge@v2
with:
target: major
github-token: ${{ secrets.mytoken }}
auto-merge:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ahmadnassri/action-dependabot-auto-merge@v2
with:
target: major
github-token: ${{ secrets.mytoken }}
61 changes: 31 additions & 30 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,41 @@
---
name: pre-commit

on:
push:
pull_request:
push:
pull_request:

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
pre-commit:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Generate Cargo.lock
uses: actions-rs/cargo@v1
with:
command: generate-lockfile
- name: Generate Cargo.lock
uses: actions-rs/cargo@v1
with:
command: generate-lockfile

- name: Set up Python
uses: actions/setup-python@v5
- name: Set up Python
uses: actions/setup-python@v5

- name: Detect code style issues
uses: pre-commit/[email protected]
env:
SKIP: no-commit-to-branch
- name: Detect code style issues
uses: pre-commit/[email protected]
env:
SKIP: no-commit-to-branch

- name: Generate patch file
if: failure()
run: |
git diff-index -p HEAD > "${PATCH_FILE}"
[ -s "${PATCH_FILE}" ] && echo "UPLOAD_PATCH_FILE=${PATCH_FILE}" >> "${GITHUB_ENV}"
env:
PATCH_FILE: pre-commit.patch
- name: Generate patch file
if: failure()
run: |
git diff-index -p HEAD > "${PATCH_FILE}"
[ -s "${PATCH_FILE}" ] && echo "UPLOAD_PATCH_FILE=${PATCH_FILE}" >> "${GITHUB_ENV}"
env:
PATCH_FILE: pre-commit.patch

- name: Upload patch artifact
if: failure() && env.UPLOAD_PATCH_FILE != null
uses: actions/upload-artifact@v4
with:
name: ${{ env.UPLOAD_PATCH_FILE }}
path: ${{ env.UPLOAD_PATCH_FILE }}
- name: Upload patch artifact
if: failure() && env.UPLOAD_PATCH_FILE != null
uses: actions/upload-artifact@v4
with:
name: ${{ env.UPLOAD_PATCH_FILE }}
path: ${{ env.UPLOAD_PATCH_FILE }}
104 changes: 50 additions & 54 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,58 +1,54 @@
---
default_language_version:
python: python3
python: python3
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-case-conflict
- id: check-json
- id: check-merge-conflict
- id: check-symlinks
- id: check-toml
- id: check-xml
- id: check-yaml
- id: destroyed-symlinks
- id: detect-private-key
- id: end-of-file-fixer
- id: fix-byte-order-marker
- id: forbid-new-submodules
- id: mixed-line-ending
- id: trailing-whitespace
exclude: ".tsv$"
- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
- id: codespell
args: [
--ignore-words=.codespellignore
]
exclude_types: [tsv, json]
- repo: https://github.com/doublify/pre-commit-rust
rev: v1.0
hooks:
- id: fmt
args: [
--all,
--,
]
- id: clippy
args: [
--locked,
--workspace,
--all-features,
--all-targets,
--,
-D,
warnings,
]
- repo: https://github.com/Holzhaus/sourceheaders
rev: v0.0.4
hooks:
- id: sourceheaders
- repo: https://github.com/jorisroovers/gitlint
rev: v0.19.1
hooks:
- id: gitlint
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-case-conflict
- id: check-json
- id: check-merge-conflict
- id: check-symlinks
- id: check-toml
- id: check-xml
- id: check-yaml
- id: destroyed-symlinks
- id: detect-private-key
- id: end-of-file-fixer
- id: fix-byte-order-marker
- id: forbid-new-submodules
- id: mixed-line-ending
- id: trailing-whitespace
exclude: .tsv$
- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
- id: codespell
args: [--ignore-words=.codespellignore]
exclude_types: [tsv, json]
- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: black
- repo: https://github.com/jumanjihouse/pre-commit-hook-yamlfmt
rev: 0.2.1
hooks:
- id: yamlfmt
- repo: https://github.com/doublify/pre-commit-rust
rev: v1.0
hooks:
- id: fmt
args: [--all, --]
- id: clippy
args: [--locked, --workspace, --all-features, --all-targets, --, -D, warnings]
- repo: https://github.com/Holzhaus/sourceheaders
rev: v0.0.4
hooks:
- id: sourceheaders
- repo: https://github.com/jorisroovers/gitlint
rev: v0.19.1
hooks:
- id: gitlint

ci:
skip: [fmt, clippy]
skip: [fmt, clippy]
Loading