Skip to content

Commit 0e3ec7d

Browse files
committed
Add precious workflow
1 parent 73277fa commit 0e3ec7d

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

.github/workflows/precious.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Precious
2+
3+
on:
4+
push:
5+
branches:
6+
- 'main'
7+
pull_request:
8+
workflow_dispatch:
9+
10+
jobs:
11+
code-formatting:
12+
runs-on: ubuntu-latest
13+
name: Code Formatting
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
- name: Fetch base ref
20+
if: ${{ github.event.pull_request }}
21+
run: git fetch origin ${{ github.base_ref }}:upstream
22+
- name: Install precious
23+
run: ./bin/install-precious /usr/local/bin
24+
- run: git diff --name-only --diff-filter=ACM upstream...
25+
- name: Select files
26+
id: select-files
27+
run: |
28+
if [[ -n "${{ github.event.pull_request.number }}" ]]; then
29+
echo 'precious-args=--git-diff-from upstream' >> "$GITHUB_OUTPUT"
30+
else
31+
echo 'precious-args=--all' >> "$GITHUB_OUTPUT"
32+
fi
33+
- name: Lint files
34+
run: precious lint ${{ steps.select-files.outputs.precious-args }}

bin/install-precious

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env bash
2+
3+
# This is for installing precious and other 3rd party libs needed for linting
4+
# in CI
5+
6+
set -euo pipefail
7+
8+
if [ -z "${1:-}" ]; then
9+
echo "usage: ./bin/install-precious /path/to/bin/dir"
10+
exit 1
11+
fi
12+
13+
TARGET=$1
14+
export TARGET
15+
16+
TARGET=$1
17+
export TARGET
18+
19+
curl --silent --location \
20+
https://raw.githubusercontent.com/houseabsolute/ubi/master/bootstrap/bootstrap-ubi.sh |
21+
sh
22+
23+
ubi --project houseabsolute/omegasort --in "$TARGET"
24+
ubi --project houseabsolute/precious --in "$TARGET"

0 commit comments

Comments
 (0)