diff --git a/package.json b/package.json index e6997c8ae68..408ef3b8580 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "build": "npm run get-location-data && npm run build-glean && npm run build-nimbus && next build && npm run build-cronjobs", "cloudrun": "npm run db:migrate && npm start", "start": "next start", - "lint": "stylelint '**/*.scss' && prettier --check './src' && next lint --max-warnings=0 && tsc -p tsconfig.json --noEmit", + "lint": "stylelint '**/*.scss' && prettier --check './src' && next lint --max-warnings=0 && tsc -p tsconfig.json --noEmit && npm run validate-nimbus", "fix": "prettier --write './src' && next lint --fix && stylelint --fix '**/*.scss'", "test": "npm run build-nimbus && jest", "e2e": "playwright test src/e2e/", @@ -48,7 +48,8 @@ "build-glean-types": "node src/scripts/build/gleanTypes.js", "build-glean-docs": "npm run build-glean-frontend-docs && npm run build-glean-backend-docs", "build-glean-frontend-docs": "glean translate src/telemetry/metrics.yaml --format markdown --output docs/telemetry/frontent", - "build-glean-backend-docs": "glean translate src/telemetry/backend-metrics.yaml --format markdown --output docs/telemetry/backend" + "build-glean-backend-docs": "glean translate src/telemetry/backend-metrics.yaml --format markdown --output docs/telemetry/backend", + "validate-nimbus": "sh src/scripts/validate-nimbus-file.sh" }, "repository": { "type": "git", diff --git a/src/scripts/validate-nimbus-file.sh b/src/scripts/validate-nimbus-file.sh new file mode 100644 index 00000000000..3cb52264dc7 --- /dev/null +++ b/src/scripts/validate-nimbus-file.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +TARGET_PATH=/tmp/nimbus-cli +NIMBUS_INSTALL_REMOTE_PATH=https://raw.githubusercontent.com/mozilla/application-services/main/install-nimbus-cli.sh +NIMBUS_INSTALL_LOCAL_PATH=$TARGET_PATH/install.sh + +if command -v "${TARGET_PATH}/nimbus-cli"; then + echo "Skip installation of \`nimbus-cli\`" +else + if [ -d "${TARGET_PATH}" ]; then + echo "Directory for \`nimbus-cli\` already exists: $TARGET_PATH" + else + echo "Create directory for \`nimbus-cli\`: $TARGET_PATH" + mkdir -p $TARGET_PATH + fi + + if [ -f "${NIMBUS_INSTALL_LOCAL_PATH}" ]; then + echo "Skip download of \`nimbus-cli\` installer" + else + echo "Download \`nimbus-cli\` installer from $NIMBUS_INSTALL_REMOTE_PATH to $TARGET_PATH" + curl --proto '=https' --tlsv1.2 -sSf -o "$NIMBUS_INSTALL_LOCAL_PATH" "$NIMBUS_INSTALL_REMOTE_PATH" + fi + + echo "Install \`nimbus-cli\`" + bash $NIMBUS_INSTALL_LOCAL_PATH --directory $TARGET_PATH +fi + +echo "Lint nimbus.yaml" +$TARGET_PATH/nimbus-cli fml -- validate config/nimbus.yaml