Skip to content

Commit

Permalink
chore: various tooling & community improvements (#131)
Browse files Browse the repository at this point in the history
- **fix(ci): ensure clippy runs with all features**
- **chore(ci): coverage using llvm-cov**
- **chore: drastically improve changelog generation**
- **chore(ci): add sanity checks for pull requests**
- **chore(ci): split jobs and add typos**
  • Loading branch information
timonv authored Jul 7, 2024
1 parent 84dd65d commit 51c114c
Show file tree
Hide file tree
Showing 11 changed files with 833 additions and 319 deletions.
75 changes: 37 additions & 38 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,37 @@
# name: Coverage
#
# on:
# pull_request:
# push:
# branches:
# - master
#
# concurrency:
# group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
# cancel-in-progress: true
#
# jobs:
# test:
# name: coverage
# runs-on: ubuntu-latest
# services:
# qdrant:
# image: qdrant/qdrant:v1.9.7
# ports:
# - 6334:6334
# env:
# RUST_LOG: swiftide=debug
# RUST_BACKTRACE: 1
# QDRANT_URL: http://qdrant:6334
# container:
# image: xd009642/tarpaulin:develop-nightly
# options: --security-opt seccomp=unconfined
# steps:
# - name: Checkout repository
# uses: actions/checkout@v4
#
# - name: Generate code coverage
# run: |
# cargo tarpaulin --verbose --all-features -p swiftide --timeout 120 --out xml
#
# - name: Coveralls
# uses: coverallsapp/github-action@v2
name: Coverage

on:
pull_request:
push:
branches:
- master

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
test:
name: coverage
runs-on: ubuntu-latest
env:
RUST_LOG: swiftide=debug
RUST_BACKTRACE: 1
steps:
- name: Checkout repository
uses: actions/checkout@v4

- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy,rustfmt
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@v2
with:
tool: cargo-llvm-cov
- name: Generate code coverage
run: |
cargo llvm-cov --lcov --output-path target/lcov.info --all-features
- name: Coveralls
uses: coverallsapp/github-action@v2
86 changes: 86 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: Check Pull Requests

on:
pull_request_target:
types:
- opened
- edited
- synchronize
- labeled
- unlabeled
merge_group:

permissions:
pull-requests: write

jobs:
check-title:
runs-on: ubuntu-latest
steps:
- name: Check PR title
if: github.event_name == 'pull_request_target'
uses: amannn/action-semantic-pull-request@v5
id: check_pr_title
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Add comment indicating we require pull request titles to follow conventional commits specification
- uses: marocchino/sticky-pull-request-comment@v2
if: always() && (steps.check_pr_title.outputs.error_message != null)
with:
header: pr-title-lint-error
message: |
Thank you for opening this pull request!
We require pull request titles to follow the [Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/) and it looks like your proposed title needs to be adjusted.
Details:
> ${{ steps.check_pr_title.outputs.error_message }}
# Delete a previous comment when the issue has been resolved
- if: ${{ steps.check_pr_title.outputs.error_message == null }}
uses: marocchino/sticky-pull-request-comment@v2
with:
header: pr-title-lint-error
delete: true

check-breaking-change-label:
runs-on: ubuntu-latest
env:
# use an environment variable to pass untrusted input to the script
# see https://securitylab.github.com/research/github-actions-untrusted-input/
PR_TITLE: ${{ github.event.pull_request.title }}
steps:
- name: Check breaking change label
id: check_breaking_change
run: |
pattern='^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\(\w+\))?!:'
# Check if pattern matches
if echo "${PR_TITLE}" | grep -qE "$pattern"; then
echo "breaking_change=true" >> $GITHUB_OUTPUT
else
echo "breaking_change=false" >> $GITHUB_OUTPUT
fi
- name: Add label
if: steps.check_breaking_change.outputs.breaking_change == 'true'
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['breaking change']
})
do-not-merge:
if: ${{ contains(github.event.*.labels.*.name, 'do not merge') }}
name: Prevent Merging
runs-on: ubuntu-latest
steps:
- name: Check for label
run: |
echo "Pull request is labeled as 'do not merge'"
echo "This workflow fails so that the pull request cannot be merged"
exit 1
39 changes: 33 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test
name: CI

on:
pull_request:
Expand All @@ -13,10 +13,11 @@ concurrency:

env:
CARGO_TERM_COLOR: always
RUSTFLAGS: "-Dwarnings"

jobs:
lint-and-test:
name: Lint & Test
lint:
name: Lint
runs-on: ubuntu-latest

env:
Expand All @@ -26,11 +27,37 @@ jobs:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy,rustfmt
components: rustfmt
- uses: r7kamura/rust-problem-matchers@v1
- name: "Clippy"
run: cargo clippy
- name: Check typos
uses: crate-ci/typos@master
- name: "Rustfmt"
run: cargo fmt --all --check

test:
name: Test
runs-on: ubuntu-latest
env:
RUST_LOG: DEBUG
RUST_BACKTRACE: 1
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: r7kamura/rust-problem-matchers@v1
- name: "Test"
run: cargo test --verbose --workspace --all-features

clippy:
name: Clippy
runs-on: ubuntu-latest
env:
RUST_LOG: DEBUG
RUST_BACKTRACE: 1
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy,rustfmt
- uses: r7kamura/rust-problem-matchers@v1
- name: "Clippy"
run: cargo clippy --all-targets --all-features
Loading

0 comments on commit 51c114c

Please sign in to comment.