Skip to content

Commit a8f1e35

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

1 file changed

Lines changed: 123 additions & 0 deletions

File tree

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
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+
- uses: actions/setup-node@v5
23+
if: inputs.web
24+
with:
25+
node-version: ${{ env.NODE_VERSION }}
26+
cache: 'npm'
27+
- shell: bash
28+
name: Setup yarn
29+
if: inputs.web
30+
run: npm install -g yarn
31+
- name: Install yq
32+
shell: bash
33+
run: |
34+
YQ="$HOME/.local/bin/yq"
35+
mkdir -p "$(dirname "$YQ")"
36+
37+
if [[ "$RUNNER_OS" == "Linux" ]]; then
38+
curl -L -o "$YQ" https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64
39+
elif [[ "$RUNNER_OS" == "macOS" ]]; then
40+
curl -L -o "$YQ" https://github.com/mikefarah/yq/releases/latest/download/yq_darwin_amd64
41+
else
42+
echo "Unsupported OS: $RUNNER_OS"
43+
exit 1
44+
fi
45+
46+
chmod +x "$YQ"
47+
echo "$HOME/.local/bin" >> $GITHUB_PATH
48+
- name: Dependencies (Flutter)
49+
if: inputs.flutter
50+
shell: bash
51+
run: |
52+
OUTPUT_FILE="dart-deps.csv"
53+
> "$OUTPUT_FILE"
54+
55+
echo "package,version" >> "$OUTPUT_FILE"
56+
57+
find . -name "pubspec.lock" | while read -r LOCK_FILE; do
58+
PACKAGES_JSON=$(yq -o=json eval '.packages' "$LOCK_FILE")
59+
60+
echo "$PACKAGES_JSON" | jq -r 'to_entries[] | "\(.key),\(.value.version)"' >> "$OUTPUT_FILE"
61+
done
62+
- name: Dependencies (Web)
63+
if: inputs.web
64+
shell: bash
65+
run: |
66+
OUTPUT_FILE="yarn-deps.csv"
67+
> "$OUTPUT_FILE"
68+
echo "package,version" >> "$OUTPUT_FILE"
69+
70+
find . -name "yarn.lock" -not -path "*/node_modules/*" -exec awk '
71+
/^"?[^"]*"?:$/ {
72+
line = $0
73+
sub(/:$/,"",line)
74+
gsub(/^"/,"",line)
75+
gsub(/"$/,"",line)
76+
77+
n = split(line, keys, ", *")
78+
delete pkgnames
79+
for (i=1; i<=n; i++) {
80+
k = keys[i]
81+
gsub(/^ *"/,"",k)
82+
gsub(/" *$/,"",k)
83+
84+
if (substr(k,1,1)=="@") {
85+
if (match(k, /@[^\/]*\/[^@]*@/)) {
86+
pkgname = substr(k, 1, RSTART + RLENGTH - 2)
87+
} else {
88+
pkgname = k
89+
}
90+
} else {
91+
if (match(k, /@[^@]*$/)) {
92+
pkgname = substr(k, 1, RSTART-1)
93+
} else {
94+
pkgname = k
95+
}
96+
}
97+
pkgnames[pkgname] = 1
98+
}
99+
next
100+
}
101+
102+
/^ version / {
103+
gsub(/^[[:space:]]*version[[:space:]]*"/,"")
104+
gsub(/".*$/,"")
105+
version = $0
106+
for (p in pkgnames) {
107+
print p "," version
108+
}
109+
delete pkgnames
110+
}
111+
' {} + >> "$OUTPUT_FILE"
112+
- uses: actions/upload-artifact@v4
113+
if: inputs.flutter
114+
with:
115+
name: dart-deps
116+
path: dart-deps.csv
117+
- uses: actions/upload-artifact@v4
118+
if: inputs.web
119+
with:
120+
name: yarn-deps
121+
path: yarn-deps.csv
122+
- uses: QuickBirdEng/actions/soup-version-check@main
123+

0 commit comments

Comments
 (0)