diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 22c53c109a6..5dddac38181 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -13,7 +13,11 @@ jobs: uses: ./.github/actions/install_runner - run: source venv/bin/activate shell: bash - - name: Black, pylint, tailing whitespaces, and yaml checks + - name: Install node + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 + with: + node-version: 20 + - name: Black, pylint, tailing whitespaces, yaml, shellcheck, and language-specific checks shell: bash run: ./format.sh --check - if: ${{ failure() }} @@ -24,25 +28,3 @@ jobs: exit 1 ' - - name: 'Install shellcheck' - shell: bash - run: sudo apt-get install -y shellcheck - - name: 'Run shellcheck' - shell: bash - run: ./utils/scripts/shellcheck.sh - - name: Install node - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 - with: - node-version: 20 - - name: 'Run nodejs express lint' - shell: bash - working-directory: ./utils/build/docker/nodejs/express - run: | - npm install - npm run lint - - name: 'Run nodejs fastify lint' - shell: bash - working-directory: ./utils/build/docker/nodejs/fastify - run: | - npm install - npm run lint diff --git a/.shellcheck b/.shellcheck index 0cc42737315..d702c6458d5 100644 --- a/.shellcheck +++ b/.shellcheck @@ -33,4 +33,5 @@ TODO=( utils/interfaces/schemas/serve.sh build.sh format.sh + *node_modules* ) diff --git a/format.sh b/format.sh index 0fe2857ede8..b26b423c810 100755 --- a/format.sh +++ b/format.sh @@ -44,12 +44,6 @@ if ! mypy --config pyproject.toml; then exit 1 fi -echo "Running ruff checks..." -if ! which ruff > /dev/null; then - echo "ruff is not installed, installing it (ETA 5s)" - ./build.sh -i runner > /dev/null -fi - echo "Running ruff formatter..." if [ "$COMMAND" == "fix" ]; then ruff format @@ -133,11 +127,6 @@ else fi echo "Running yamllint checks..." -if ! which ./venv/bin/yamllint > /dev/null; then - echo "yamllint is not installed, installing it (ETA 60s)" - ./build.sh -i runner > /dev/null -fi - if ! ./venv/bin/yamllint -s manifests/; then echo "yamllint checks failed. Please fix the errors above. 💥 💔 💥" exit 1 @@ -149,5 +138,29 @@ if ! python ./manifests/parser/core.py; then exit 1 fi +echo "Running shellcheck checks..." +if ! ./utils/scripts/shellcheck.sh; then + echo "shellcheck checks failed. Please fix the errors above. 💥 💔 💥" + exit 1 +fi + +echo "Running language-specific linters..." +# This will not run if npm is not installed as written and there is no "install" step today +# TODO: Install node as part of this script +if which npm > /dev/null; then + echo "Running Node.js linters" + + # currently only fastify requires linting + # this can be added later + nodejs_dirs=("express" "fastify") + + for dir in "${nodejs_dirs[@]}"; do + if ! NODE_NO_WARNINGS=1 npm --prefix ./utils/build/docker/nodejs/"$dir" install --silent && npm --prefix ./utils/build/docker/nodejs/"$dir" run --silent lint; then + echo "$dir linter failed. Please fix the errors above. 💥 💔 💥" + exit 1 + fi + done +fi + echo "All good, the system-tests CI will be happy! ✨ 🍰 ✨" diff --git a/requirements.txt b/requirements.txt index 70f94d5188f..950a1467995 100644 --- a/requirements.txt +++ b/requirements.txt @@ -36,6 +36,7 @@ ruff==0.8.1 scp==0.14.5 semantic-version==2.10.0 setuptools==75.8.0 +shellcheck-py==0.11.0.1 types-aiofiles==24.1.0.20241221 types-protobuf==5.29.1.20241207 types-python-dateutil==2.9.0.20241206 diff --git a/utils/build/docker/nodejs/express/package-lock.json b/utils/build/docker/nodejs/express/package-lock.json index 6bba37ccb6f..03669eeffab 100644 --- a/utils/build/docker/nodejs/express/package-lock.json +++ b/utils/build/docker/nodejs/express/package-lock.json @@ -9,6 +9,8 @@ "version": "1.0.0", "license": "ISC", "dependencies": { + "@openfeature/core": "^1.9.0", + "@openfeature/server-sdk": "~1.19.0", "@opentelemetry/api": "^1.9.0", "@opentelemetry/core": "^1.30.1", "amqplib": "^0.10.3", @@ -547,6 +549,24 @@ "node": ">= 8" } }, + "node_modules/@openfeature/core": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/@openfeature/core/-/core-1.9.1.tgz", + "integrity": "sha512-YySPtH4s/rKKnHRU0xyFGrqMU8XA+OIPNWDrlEFxE6DCVWCIrxE5YpiB94YD2jMFn6SSdA0cwQ8vLkCkl8lm8A==", + "license": "Apache-2.0" + }, + "node_modules/@openfeature/server-sdk": { + "version": "1.19.0", + "resolved": "https://registry.npmjs.org/@openfeature/server-sdk/-/server-sdk-1.19.0.tgz", + "integrity": "sha512-sxmYKkBCpWWkKX2xJt6bFK15dorfR2lH27lkeKduTFPXRMV+pO7eORUelI9gctXhxvfXbDGK94ybq5fiso3/vg==", + "license": "Apache-2.0", + "engines": { + "node": ">=20" + }, + "peerDependencies": { + "@openfeature/core": "^1.9.0" + } + }, "node_modules/@opentelemetry/api": { "version": "1.9.0", "resolved": "https://registry.npmjs.org/@opentelemetry/api/-/api-1.9.0.tgz", @@ -5985,6 +6005,17 @@ "fastq": "^1.6.0" } }, + "@openfeature/core": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/@openfeature/core/-/core-1.9.1.tgz", + "integrity": "sha512-YySPtH4s/rKKnHRU0xyFGrqMU8XA+OIPNWDrlEFxE6DCVWCIrxE5YpiB94YD2jMFn6SSdA0cwQ8vLkCkl8lm8A==" + }, + "@openfeature/server-sdk": { + "version": "1.19.0", + "resolved": "https://registry.npmjs.org/@openfeature/server-sdk/-/server-sdk-1.19.0.tgz", + "integrity": "sha512-sxmYKkBCpWWkKX2xJt6bFK15dorfR2lH27lkeKduTFPXRMV+pO7eORUelI9gctXhxvfXbDGK94ybq5fiso3/vg==", + "requires": {} + }, "@opentelemetry/api": { "version": "1.9.0", "resolved": "https://registry.npmjs.org/@opentelemetry/api/-/api-1.9.0.tgz", diff --git a/utils/scripts/shellcheck.sh b/utils/scripts/shellcheck.sh index 400ba5ddd03..530445291fa 100755 --- a/utils/scripts/shellcheck.sh +++ b/utils/scripts/shellcheck.sh @@ -9,8 +9,8 @@ function has() { shift local e - for e; do [[ "${e}" == "${needle}" ]] && return 0; done - + # shellcheck disable=SC2053 # explicitly allow glob matching + for e in "$@"; do [[ $needle == $e ]] && return 0; done return 1 } @@ -43,7 +43,7 @@ function lint() { files+=("$f") done < <( find utils -name '*.sh'; ls -1 -- *.sh ) - shellcheck "${files[@]}" + ./venv/bin/shellcheck "${files[@]}" } function root() {