Skip to content

Commit

Permalink
Add precious workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
dhogan8 committed Jul 30, 2024
1 parent 73277fa commit edf3239
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/precious.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Precious

on:
push:
branches:
- 'main'
pull_request:
workflow_dispatch:

jobs:
code-formatting:
runs-on: ubuntu-latest
name: Code Formatting
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install precious
run: ./bin/install-precious /usr/local/bin
- run: git diff --name-only --diff-filter=ACM upstream...
- name: Select files
id: select-files
run: |
if [[ -n "${{ github.event.pull_request.number }}" ]]; then
echo 'precious-args=--git-diff-from main' >> "$GITHUB_OUTPUT"
else
echo 'precious-args=--all' >> "$GITHUB_OUTPUT"
fi
- name: Lint files
run: precious lint ${{ steps.select-files.outputs.precious-args }}
24 changes: 24 additions & 0 deletions bin/install-precious
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash

# This is for installing precious and other 3rd party libs needed for linting
# in CI

set -euo pipefail

if [ -z "${1:-}" ]; then
echo "usage: ./bin/install-precious /path/to/bin/dir"
exit 1
fi

TARGET=$1
export TARGET

TARGET=$1
export TARGET

curl --silent --location \
https://raw.githubusercontent.com/houseabsolute/ubi/master/bootstrap/bootstrap-ubi.sh |
sh

ubi --project houseabsolute/omegasort --in "$TARGET"
ubi --project houseabsolute/precious --in "$TARGET"

0 comments on commit edf3239

Please sign in to comment.