File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+ set -euo pipefail
3+
4+ if [ " $# " -eq 0 ]; then
5+ echo " Usage: $0 [--python-venv] <command:package> [command:package ...]" >&2
6+ exit 1
7+ fi
8+
9+ CHECK_PYTHON_VENV=0
10+ CHECKS=()
11+
12+ for arg in " $@ " ; do
13+ case " $arg " in
14+ --python-venv)
15+ CHECK_PYTHON_VENV=1
16+ ;;
17+ * )
18+ CHECKS+=(" $arg " )
19+ ;;
20+ esac
21+ done
22+
23+ if [ " ${# CHECKS[@]} " -eq 0 ]; then
24+ echo " No command checks provided." >&2
25+ exit 1
26+ fi
27+
28+ MISSING_PKGS=()
29+
30+ add_pkg () {
31+ local pkg=" $1 "
32+ for existing in " ${MISSING_PKGS[@]} " ; do
33+ if [ " $existing " = " $pkg " ]; then
34+ return
35+ fi
36+ done
37+ MISSING_PKGS+=(" $pkg " )
38+ }
39+
40+ for item in " ${CHECKS[@]} " ; do
41+ if [[ " $item " != * :* ]]; then
42+ echo " Invalid check '$item '. Expected format command:package." >&2
43+ exit 1
44+ fi
45+
46+ cmd=" ${item%%:* } "
47+ pkg=" ${item#*: } "
48+
49+ if ! command -v " $cmd " > /dev/null 2>&1 ; then
50+ echo " Missing tool: $cmd (package: $pkg )"
51+ add_pkg " $pkg "
52+ fi
53+ done
54+
55+ if [ " $CHECK_PYTHON_VENV " -eq 1 ]; then
56+ if ! command -v python3 > /dev/null 2>&1 ; then
57+ echo " Missing tool: python3 (required for venv check)"
58+ add_pkg " python3"
59+ echo " Missing module: venv (package: python3-venv)"
60+ add_pkg " python3-venv"
61+ elif ! python3 -m venv --help > /dev/null 2>&1 ; then
62+ echo " Missing module: venv (package: python3-venv)"
63+ add_pkg " python3-venv"
64+ fi
65+ fi
66+
67+ if [ " ${# MISSING_PKGS[@]} " -gt 0 ]; then
68+ apt-get update
69+ apt-get install -y " ${MISSING_PKGS[@]} "
70+ fi
Original file line number Diff line number Diff line change @@ -30,15 +30,22 @@ jobs:
3030 command : lint
3131 name : ${{ matrix.name }}
3232 steps :
33- - name : Install Essentials
34- run : |
35- apt-get update && apt-get install -y nodejs npm wget git tar xz-utils pipx python3-venv
36-
3733 - name : Checkout code
3834 uses : https://code.forgejo.org/actions/checkout@v6
3935 with :
4036 fetch-depth : 0
4137
38+ - name : Ensure required tools
39+ shell : bash
40+ run : |
41+ bash ./.forgejo/scripts/ensure-tools.sh \
42+ --python-venv \
43+ wget:wget \
44+ git:git \
45+ tar:tar \
46+ python3:python3 \
47+ pipx:pipx
48+
4249 - name : Install Just
4350 run : |
4451 case "$(uname -m)" in
Original file line number Diff line number Diff line change @@ -11,15 +11,19 @@ jobs:
1111 if : startsWith(github.event.head_commit.message, 'RELEASE:') || startsWith(github.event.head_commit.message, 'release:')
1212 runs-on : ubuntu-latest
1313 steps :
14- - name : Install Essentials
15- run : |
16- apt-get update && apt-get install -y nodejs npm wget curl
17-
1814 - name : Checkout code
1915 uses : https://code.forgejo.org/actions/checkout@v6
2016 with :
2117 fetch-depth : 0
2218
19+ - name : Ensure required tools
20+ shell : bash
21+ run : |
22+ bash ./.forgejo/scripts/ensure-tools.sh \
23+ git:git \
24+ curl:curl \
25+ python3:python3
26+
2327 - name : Extract tag from commit message
2428 id : extract_tag
2529 run : |
Original file line number Diff line number Diff line change @@ -18,15 +18,19 @@ jobs:
1818 name : Unit Tests
1919 runs-on : ubuntu-latest
2020 steps :
21- - name : Install Essentials
22- run : |
23- apt-get update && apt-get install -y nodejs npm wget git tar xz-utils
24-
2521 - name : Checkout code
2622 uses : https://code.forgejo.org/actions/checkout@v6
2723 with :
2824 fetch-depth : 0
2925
26+ - name : Ensure required tools
27+ shell : bash
28+ run : |
29+ bash ./.forgejo/scripts/ensure-tools.sh \
30+ wget:wget \
31+ git:git \
32+ tar:tar
33+
3034 - name : Install Neovim
3135 run : |
3236 case "$(uname -m)" in
@@ -78,15 +82,26 @@ jobs:
7882 name : Contract Tests
7983 runs-on : ubuntu-latest
8084 steps :
81- - name : Install Essentials
82- run : |
83- apt-get update && apt-get install -y nodejs npm wget git tar xz-utils
84-
8585 - name : Checkout code
8686 uses : https://code.forgejo.org/actions/checkout@v6
8787 with :
8888 fetch-depth : 0
8989
90+ - name : Ensure required tools
91+ shell : bash
92+ run : |
93+ bash ./.forgejo/scripts/ensure-tools.sh \
94+ node:nodejs \
95+ npm:npm \
96+ wget:wget \
97+ git:git \
98+ tar:tar
99+
100+ - name : Verify Node.js
101+ run : |
102+ node --version
103+ npm --version
104+
90105 - name : Install Neovim
91106 run : |
92107 case "$(uname -m)" in
You can’t perform that action at this time.
0 commit comments