-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
111 lines (99 loc) · 3.39 KB
/
Copy pathaction.yml
File metadata and controls
111 lines (99 loc) · 3.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
name: 'Align codebase'
description: 'Check monorepo structural alignment against rules defined in align.toml'
branding:
color: orange
icon: chevron-up
inputs:
config:
description: 'Path to align.toml config file'
required: false
default: 'align.toml'
version:
description: 'Release version to use (e.g. v0.1.0). Default: latest'
required: false
default: 'latest'
outputs:
passed:
description: 'Number of checks that passed'
value: ${{ steps.run.outputs.passed }}
failed:
description: 'Number of checks that failed'
value: ${{ steps.run.outputs.failed }}
total:
description: 'Total number of checks'
value: ${{ steps.run.outputs.total }}
runs:
using: 'composite'
steps:
- name: Detect platform
id: platform
shell: bash
run: |
ARCH=$(uname -m)
case "$ARCH" in
x86_64) ARCH="x86_64" ;;
aarch64|arm64) ARCH="aarch64" ;;
*) echo "::error::Unsupported architecture: $ARCH"; exit 1 ;;
esac
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
case "$OS" in
linux) PLATFORM="${ARCH}-linux" ;;
darwin) PLATFORM="${ARCH}-macos" ;;
*) echo "::error::Unsupported OS: $OS"; exit 1 ;;
esac
echo "archive=align-${PLATFORM}.tar.gz" >> "$GITHUB_OUTPUT"
- name: Download binary
shell: bash
run: |
VERSION="${{ inputs.version }}"
ARCHIVE="${{ steps.platform.outputs.archive }}"
REPO="${{ github.action_repository }}"
if [ "$VERSION" = "latest" ]; then
URL="https://github.com/${REPO}/releases/latest/download/${ARCHIVE}"
else
URL="https://github.com/${REPO}/releases/download/${VERSION}/${ARCHIVE}"
fi
curl -fsSL "$URL" | tar xz -C /tmp
chmod +x /tmp/align
- name: Register problem matcher
shell: bash
run: echo "::add-matcher::${{ github.action_path }}/problem-matcher.json"
- name: Run align
id: run
shell: bash
run: |
set +e
OUTPUT=$(/tmp/align --config "${{ inputs.config }}" --format json)
EXIT_CODE=$?
set -e
PASSED=$(echo "$OUTPUT" | jq -r '.passed')
FAILED=$(echo "$OUTPUT" | jq -r '.failed')
TOTAL=$(echo "$OUTPUT" | jq -r '.total')
echo "passed=$PASSED" >> "$GITHUB_OUTPUT"
echo "failed=$FAILED" >> "$GITHUB_OUTPUT"
echo "total=$TOTAL" >> "$GITHUB_OUTPUT"
# Emit FAIL lines for problem matcher
echo "$OUTPUT" | jq -r '.results[] | select(.status == "FAIL") | "FAIL \(.rule) \(.path) \(.message)"'
# Job summary
{
echo "## Align Results"
echo ""
if [ "$FAILED" -eq 0 ]; then
echo "All **${TOTAL}** checks passed."
else
echo "**${FAILED}** of **${TOTAL}** checks failed."
fi
echo ""
echo "<details><summary>Details (${PASSED} passed, ${FAILED} failed)</summary>"
echo ""
echo "| Status | Rule | Path | Message |"
echo "|--------|------|------|---------|"
echo "$OUTPUT" | jq -r '.results[] | "| \(.status) | \(.rule) | \(.path) | \(.message) |"'
echo ""
echo "</details>"
} >> "$GITHUB_STEP_SUMMARY"
exit $EXIT_CODE
- name: Deregister problem matcher
if: always()
shell: bash
run: echo "::remove-matcher owner=align::"