Skip to content

Commit a58a7ae

Browse files
committed
add soup check workflow
1 parent 9e6571e commit a58a7ae

1 file changed

Lines changed: 104 additions & 0 deletions

File tree

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
name: SOUP Version Check
2+
env:
3+
ENVIRONMENT_FILE: .env
4+
NODE_VERSION: '20.12.1'
5+
6+
on:
7+
workflow_call:
8+
inputs:
9+
flutter:
10+
description: 'Web Working directory for action'
11+
type: boolean
12+
default: false
13+
web:
14+
description: 'Web Working directory for action'
15+
type: boolean
16+
default: false
17+
jobs:
18+
version_check:
19+
runs-on: [self-hosted, Linux]
20+
steps:
21+
- uses: actions/checkout@v3
22+
- name: Install yq
23+
shell: bash
24+
run: |
25+
YQ="$HOME/.local/bin/yq"
26+
mkdir -p "$(dirname "$YQ")"
27+
28+
if [[ "$RUNNER_OS" == "Linux" ]]; then
29+
curl -L -o "$YQ" https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64
30+
elif [[ "$RUNNER_OS" == "macOS" ]]; then
31+
curl -L -o "$YQ" https://github.com/mikefarah/yq/releases/latest/download/yq_darwin_amd64
32+
else
33+
echo "Unsupported OS: $RUNNER_OS"
34+
exit 1
35+
fi
36+
37+
chmod +x "$YQ"
38+
echo "$HOME/.local/bin" >> $GITHUB_PATH
39+
- name: Dependencies (Flutter)
40+
if: inputs.flutter
41+
shell: bash
42+
run: |
43+
OUTPUT_FILE="dart-deps.csv"
44+
> "$OUTPUT_FILE"
45+
46+
echo "package,version" >> "$OUTPUT_FILE"
47+
48+
find . -name "pubspec.lock" | while read -r LOCK_FILE; do
49+
PACKAGES_JSON=$(yq -o=json eval '.packages' "$LOCK_FILE")
50+
51+
echo "$PACKAGES_JSON" | jq -r 'to_entries[] | "\(.key),\(.value.version)"' >> "$OUTPUT_FILE"
52+
done
53+
- name: Dependencies (Web)
54+
if: inputs.web
55+
shell: bash
56+
run: |
57+
OUTPUT_FILE="yarn-deps.csv"
58+
> "$OUTPUT_FILE"
59+
echo "package,version" >> "$OUTPUT_FILE"
60+
61+
find . -name "yarn.lock" -not -path "*/node_modules/*" -exec awk '
62+
/^"?[^"]*"?:$/ {
63+
line = $0
64+
sub(/:$/,"",line)
65+
gsub(/^"/,"",line)
66+
gsub(/"$/,"",line)
67+
68+
n = split(line, keys, ", *")
69+
delete pkgnames
70+
for (i=1; i<=n; i++) {
71+
k = keys[i]
72+
gsub(/^ *"/,"",k)
73+
gsub(/" *$/,"",k)
74+
75+
if (substr(k,1,1)=="@") {
76+
if (match(k, /@[^\/]*\/[^@]*@/)) {
77+
pkgname = substr(k, 1, RSTART + RLENGTH - 2)
78+
} else {
79+
pkgname = k
80+
}
81+
} else {
82+
if (match(k, /@[^@]*$/)) {
83+
pkgname = substr(k, 1, RSTART-1)
84+
} else {
85+
pkgname = k
86+
}
87+
}
88+
pkgnames[pkgname] = 1
89+
}
90+
next
91+
}
92+
93+
/^ version / {
94+
gsub(/^[[:space:]]*version[[:space:]]*"/,"")
95+
gsub(/".*$/,"")
96+
version = $0
97+
for (p in pkgnames) {
98+
print p "," version
99+
}
100+
delete pkgnames
101+
}
102+
' {} + >> "$OUTPUT_FILE"
103+
- name: SOUP Check
104+
uses: QuickBirdEng/actions/soup-version-check@main

0 commit comments

Comments
 (0)