Skip to content

Use task runner just (or VSCode "tasks") #14

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

Merged
merged 2 commits into from
Aug 20, 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
30 changes: 9 additions & 21 deletions .github/workflows/binary-builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,8 @@ on:
branches: [main]

env:
CARGO_INCREMENTAL: 0
CARGO_NET_GIT_FETCH_WITH_CLI: true
CARGO_NET_RETRY: 10
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
RUSTFLAGS: -D warnings
RUSTUP_MAX_RETRIES: 10

defaults:
run:
Expand Down Expand Up @@ -99,15 +94,6 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- uses: actions/setup-python@v5
if: startsWith(github.ref, 'refs/tags/')
with:
python-version: '3.x'

- name: Increment version
if: startsWith(github.ref, 'refs/tags/')
run: python .github/workflows/replace_version_spec.py --new-version=${{ github.ref_name }}

- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
Expand All @@ -119,13 +105,15 @@ jobs:
with:
tool: cross

- name: Build (native)
if: ${{ !matrix.cross }}
run: cargo build --manifest-path cpp-linter-lib/Cargo.toml --release --bin cpp-linter --target ${{ matrix.target }} ${{ matrix.vendered && '--features openssl-vendored' || '' }}

- name: Build (cross)
if: matrix.cross
run: cross build --manifest-path cpp-linter-lib/Cargo.toml --release --bin cpp-linter --target ${{ matrix.target }} ${{ matrix.vendered && '--features openssl-vendored' || '' }}
- name: Build
run: >-
${{ matrix.cross && 'cross' || 'cargo '}}
build
--manifest-path cpp-linter-lib/Cargo.toml
--bin cpp-linter
--release
--target ${{ matrix.target }}
${{ matrix.vendered && '--features openssl-vendored' || '' }}

- name: Prepare artifacts
run: mv target/${{ matrix.target }}/release/cpp-linter${{ runner.os == 'Windows' && '.exe' || '' }} ./cpp-linter-${{ matrix.target }}${{ runner.os == 'Windows' && '.exe' || '' }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/build-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on: [push, workflow_dispatch]

env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1

jobs:
cache-deps:
Expand Down
41 changes: 41 additions & 0 deletions .github/workflows/bump_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import argparse
from pathlib import Path
import sys
import re

VER_PATTERN = re.compile(r'^version = "(\d+)\.(\d+)\.(\d+)[^"]*" # auto', re.MULTILINE)
VER_REPLACE = 'version = "%d.%d.%d" # auto'
COMPONENTS = ("major", "minor", "patch")


class Updater:
component: str = "patch"

@staticmethod
def replace(match: re.Match[str]) -> str:
ver = [int(x) for x in match.groups()[: len(COMPONENTS)]]
for _ in range(len(ver) - 1, len(COMPONENTS)):
ver.append(0)
print("old version:", ".".join([str(x) for x in ver]))
index = COMPONENTS.index(Updater.component)
ver[index] += 1
for i in range(index + 1, 3):
ver[i] = 0
print("new version:", ".".join([str(x) for x in ver]))
return VER_REPLACE % tuple(ver)


def main():
parser = argparse.ArgumentParser()
parser.add_argument("component", default="patch", choices=COMPONENTS)
parser.parse_args(namespace=Updater)
cargo_path = Path("Cargo.toml")
doc = cargo_path.read_text(encoding="utf-8")
doc = VER_PATTERN.sub(Updater.replace, doc)
cargo_path.write_text(doc, encoding="utf-8", newline="\n")
print("Updated version in Cargo.toml")
return 0


if __name__ == "__main__":
sys.exit(main())
5 changes: 5 additions & 0 deletions .github/workflows/pre-commit-hooks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ jobs:

cargo-tools:
runs-on: ubuntu-latest

env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1

steps:
- uses: actions/checkout@v4
- run: rustup update
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/python-packaging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ on:
permissions:
contents: read

env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1

jobs:
linux:
runs-on: ubuntu-latest
Expand All @@ -35,10 +39,6 @@ jobs:
with:
python-version: '3.x'

- name: Increment version
if: startsWith(github.ref, 'refs/tags/')
run: python .github/workflows/replace_version_spec.py --new-version=${{ github.ref_name }}

- name: Calculate openssl-vendored
shell: bash
id: is-openssl-vendored
Expand Down
30 changes: 0 additions & 30 deletions .github/workflows/replace_version_spec.py

This file was deleted.

11 changes: 5 additions & 6 deletions .github/workflows/run-dev-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ on:

env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1

jobs:
cache-deps:
Expand Down Expand Up @@ -63,10 +64,10 @@ jobs:
# if: runner.os == 'Windows'
# run: vcpkg install openssl

- name: Install cargo-nextest and cargo-llvm-cov
- name: Install third-party binaries
uses: taiki-e/install-action@v2
with:
tool: cargo-nextest,cargo-llvm-cov,cargo-binstall
tool: cargo-nextest,cargo-llvm-cov,cargo-binstall,just

- name: Install llvm-cov-pretty (HTML report generator)
run: cargo binstall -y llvm-cov-pretty
Expand Down Expand Up @@ -116,15 +117,13 @@ jobs:
working-directory: cpp-linter-lib
env:
CLANG_VERSION: ${{ matrix.version }}
run: cargo llvm-cov --lib --no-report nextest
run: just test

- name: Generate Coverage HTML report
working-directory: cpp-linter-lib
env:
CLANG_VERSION: ${{ matrix.version }}
run: |
cargo llvm-cov report --json --output-path .coverage.json
llvm-cov-pretty .coverage.json
run: just pretty-cov

- name: Upload coverage data
uses: actions/upload-artifact@v4
Expand Down
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,15 @@ debug/
# End of https://www.toptal.com/developers/gitignore/api/rust,python

# ignore vscode stuff
.vscode/
.vscode/**
!.vscode/tasks.json
!.vscode/extensions.json

# mdbook builds
book

# ignore generated files
.cpp-linter_cache/
cpp-linter-py/docs/cli_args.rst
lcov.info
coverage.json
8 changes: 8 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"recommendations": [
"rust-lang.rust-analyzer",
"streetsidesoftware.code-spell-checker",
"fill-labs.dependi",
"wolfmah-vscode.just-syntax"
]
}
Loading