diff --git a/.github/workflows/_deploy-per-app.yml b/.github/workflows/_deploy-per-app.yml deleted file mode 100644 index e7396d2712..0000000000 --- a/.github/workflows/_deploy-per-app.yml +++ /dev/null @@ -1,245 +0,0 @@ -name: Deploy per app (all distros) - -on: - workflow_call: - inputs: - mode: - type: string - required: true - description: "server | workstation | rest" - distros: - type: string - required: false - default: "arch debian ubuntu fedora centos" - only_app: - type: string - required: false - default: "" - missing_only: - type: boolean - required: false - default: true - keep_stack_on_failure: - type: boolean - required: false - default: true - - # regex for discovery - server_include_re: - type: string - required: false - default: "^(web-app-|web-svc-)" - server_exclude_re: - type: string - required: false - default: "^(web-app-oauth2-proxy)$" - workstation_include_re: - type: string - required: false - default: "^(desk-|util-desk-)" - workstation_exclude_re: - type: string - required: false - default: "" - - workflow_dispatch: - inputs: - mode: - description: "server | workstation | rest" - required: true - default: "server" - distros: - description: "space-separated list" - required: true - default: "arch debian ubuntu fedora centos" - only_app: - description: "optional: run only this app" - required: false - default: "" - missing_only: - description: "build only if missing" - required: false - default: "true" - keep_stack_on_failure: - description: "keep stack up on failure" - required: false - default: "true" - - server_include_re: - required: false - default: "^(web-app-|web-svc-)" - server_exclude_re: - required: false - default: "^(web-app-oauth2-proxy)$" - workstation_include_re: - required: false - default: "^(desk-|util-desk-)" - workstation_exclude_re: - required: false - default: "" - -permissions: - contents: read - packages: read - -jobs: - discover: - name: "discover=({{ inputs.mode }})" - runs-on: ubuntu-latest - timeout-minutes: 30 - outputs: - apps: ${{ steps.out.outputs.apps }} - deploy_type: ${{ steps.out.outputs.deploy_type }} - distros: ${{ steps.out.outputs.distros }} - env: - NIX_CONFIG: | - access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} - steps: - - uses: actions/checkout@v4 - - - name: Install jq - shell: bash - run: | - set -euo pipefail - sudo apt-get update - sudo apt-get install -y jq - - - name: Start stack for discovery (arch) - shell: bash - run: | - set -euo pipefail - export INFINITO_DISTRO="arch" - make up - - - name: Compute discovery result - id: out - shell: bash - run: | - set -euo pipefail - - mode="${{ inputs.mode || github.event.inputs.mode }}" - distros="${{ inputs.distros || github.event.inputs.distros }}" - only_app="${{ inputs.only_app || github.event.inputs.only_app }}" - - server_include_re="${{ inputs.server_include_re || github.event.inputs.server_include_re }}" - server_exclude_re="${{ inputs.server_exclude_re || github.event.inputs.server_exclude_re }}" - workstation_include_re="${{ inputs.workstation_include_re || github.event.inputs.workstation_include_re }}" - workstation_exclude_re="${{ inputs.workstation_exclude_re || github.event.inputs.workstation_exclude_re }}" - - : "${mode:=server}" - : "${distros:=arch debian ubuntu fedora centos}" - - discover() { - local include_re="$1" - local exclude_re="$2" - INCLUDE_RE="${include_re}" EXCLUDE_RE="${exclude_re}" scripts/tests/discover-apps.sh - } - - all_json="$(discover '.*' '')"; [[ -n "$all_json" ]] || all_json='[]' - server_json="$(discover "${server_include_re}" "${server_exclude_re}")"; [[ -n "$server_json" ]] || server_json='[]' - workstation_json="$(discover "${workstation_include_re}" "${workstation_exclude_re}")"; [[ -n "$workstation_json" ]] || workstation_json='[]' - - case "${mode}" in - server) - apps_json="${server_json}" - deploy_type="server" - ;; - workstation) - apps_json="${workstation_json}" - deploy_type="workstation" - ;; - rest) - # rest = all - (server ∪ workstation) - apps_json="$( - jq -nc \ - --argjson all "${all_json}" \ - --argjson server "${server_json}" \ - --argjson workstation "${workstation_json}" \ - ' - def uniq: unique; - def union($a;$b): ($a + $b) | uniq; - def minus($a;$b): $a | map(select(. as $x | ($b | index($x)) | not)); - (union($server;$workstation) | uniq) as $covered - | minus($all;$covered) - | unique - ' - )" - deploy_type="server" - ;; - *) - echo "ERROR: invalid mode=${mode} (server|workstation|rest)" >&2 - exit 2 - ;; - esac - - if [[ -n "${only_app}" ]]; then - apps_json="$(jq -nc --arg a "${only_app}" '[ $a ]')" - fi - - echo "apps=${apps_json}" >> "$GITHUB_OUTPUT" - echo "deploy_type=${deploy_type}" >> "$GITHUB_OUTPUT" - echo "distros=${distros}" >> "$GITHUB_OUTPUT" - - test: - name: "deploy:${{ needs.discover.outputs.deploy_type }} app=${{ matrix.app }} (all distros)" - needs: discover - runs-on: ubuntu-latest - timeout-minutes: 240 - - strategy: - fail-fast: false - # one runner per app, but keep it serial to avoid docker-dind chaos - max-parallel: 1 - matrix: - app: ${{ fromJson(needs.discover.outputs.apps) }} - - env: - NIX_CONFIG: | - access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} - - steps: - - uses: actions/checkout@v4 - - - name: Install jq - shell: bash - run: | - set -euo pipefail - sudo apt-get update - sudo apt-get install -y jq - - - name: Run deploy (this app across all distros) - shell: bash - run: | - set -euo pipefail - - app="${{ matrix.app }}" - deploy_type="${{ needs.discover.outputs.deploy_type }}" - distros="${{ needs.discover.outputs.distros }}" - - # normalize bools (workflow_call boolean vs workflow_dispatch string) - missing_only="${{ inputs.missing_only || github.event.inputs.missing_only || 'true' }}" - keep_stack="${{ inputs.keep_stack_on_failure || github.event.inputs.keep_stack_on_failure || 'true' }}" - - normalize_bool() { - case "$1" in - true|True|TRUE|1) echo "true" ;; - false|False|FALSE|0) echo "false" ;; - *) echo "true" ;; - esac - } - missing_only="$(normalize_bool "${missing_only}")" - keep_stack="$(normalize_bool "${keep_stack}")" - - read -r -a distro_arr <<< "${distros}" - - mkdir -p logs - for distro in "${distro_arr[@]}"; do - export INFINITO_DISTRO="${distro}" - - echo "=== deploy_type=${deploy_type} distro=${distro} app=${app} ===" - args=( --type "${deploy_type}" --app "${app}" ) - if [[ "${missing_only}" == "true" ]]; then args+=( --missing ); fi - if [[ "${keep_stack}" == "true" ]]; then args+=( --keep-stack-on-failure ); fi - - scripts/tests/deploy.sh "${args[@]}" - done diff --git a/.github/workflows/test-deploy-server.yml b/.github/workflows/test-deploy-server.yml index 3b668cd740..e5854c2d50 100644 --- a/.github/workflows/test-deploy-server.yml +++ b/.github/workflows/test-deploy-server.yml @@ -2,9 +2,106 @@ name: Test Infinito.Nexus Deploy (server) on: workflow_call: + workflow_dispatch: + +permissions: + contents: read + packages: read + +env: + # KISS: configure via env only + MODE: server + DISTROS: "arch debian ubuntu fedora centos" + ONLY_APP: "" + MISSING_ONLY: "true" + KEEP_STACK: "true" + NIX_CONFIG: | + access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} jobs: server: - uses: ./.github/workflows/_deploy-per-app.yml - with: - mode: server + name: deploy:server (per app, all distros) + runs-on: ubuntu-latest + timeout-minutes: 240 + + steps: + - uses: actions/checkout@v6 + + - name: Install jq + shell: bash + run: | + set -euo pipefail + sudo apt-get update + sudo apt-get install -y jq + + - name: Start stack for discovery (arch) + shell: bash + run: | + set -euo pipefail + export INFINITO_DISTRO="arch" + make up + + - name: Discover apps (JSON) + id: discover + shell: bash + run: | + set -euo pipefail + apps="$(MODE="${MODE}" scripts/ci/discover.sh)" + [[ -n "${apps}" ]] || apps='[]' + + if [[ -n "${ONLY_APP}" ]]; then + apps="$(jq -nc --arg a "${ONLY_APP}" '[ $a ]')" + fi + + echo "apps=${apps}" >> "$GITHUB_OUTPUT" + echo "apps_json=${apps}" + + - name: Deploy each app (matrix via bash loop) + shell: bash + run: | + set -euo pipefail + + normalize_bool() { + case "${1:-}" in + true|True|TRUE|1) echo "true" ;; + false|False|FALSE|0) echo "false" ;; + *) echo "true" ;; + esac + } + + apps_json='${{ steps.discover.outputs.apps }}' + readarray -t apps < <(echo "${apps_json}" | jq -r '.[]') + + export MODE="server" + export DISTROS="${DISTROS}" + export MISSING_ONLY="$(normalize_bool "${MISSING_ONLY}")" + export KEEP_STACK="$(normalize_bool "${KEEP_STACK}")" + + for app in "${apps[@]}"; do + export APP="${app}" + scripts/ci/deploy-one-app.sh + done + + - name: Show last 200 chars on failure + if: failure() + shell: bash + run: | + echo "=== DEBUG: logs ===" + ls -la logs || true + echo + + shopt -s nullglob + for f in logs/*.log; do + echo "=== tail -c 200 $f ===" + tail -c 200 "$f" || true + echo + done + + - name: Upload deploy logs + if: ${{ always() && env.ACT != 'true' }} + uses: actions/upload-artifact@v4 + with: + name: deploy-logs-server + path: logs/ + if-no-files-found: warn + retention-days: 14 diff --git a/.github/workflows/test-deploy-universal.yml b/.github/workflows/test-deploy-universal.yml index 61145cb600..bb304cd610 100644 --- a/.github/workflows/test-deploy-universal.yml +++ b/.github/workflows/test-deploy-universal.yml @@ -2,9 +2,105 @@ name: Test Infinito.Nexus Deploy (universal-rest) on: workflow_call: + workflow_dispatch: + +permissions: + contents: read + packages: read + +env: + MODE: rest + DISTROS: "arch debian ubuntu fedora centos" + ONLY_APP: "" + MISSING_ONLY: "true" + KEEP_STACK: "true" + NIX_CONFIG: | + access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} jobs: rest: - uses: ./.github/workflows/_deploy-per-app.yml - with: - mode: rest + name: deploy:rest (per app, all distros) + runs-on: ubuntu-latest + timeout-minutes: 240 + + steps: + - uses: actions/checkout@v6 + + - name: Install jq + shell: bash + run: | + set -euo pipefail + sudo apt-get update + sudo apt-get install -y jq + + - name: Start stack for discovery (arch) + shell: bash + run: | + set -euo pipefail + export INFINITO_DISTRO="arch" + make up + + - name: Discover apps (JSON) + id: discover + shell: bash + run: | + set -euo pipefail + apps="$(MODE="${MODE}" scripts/ci/discover.sh)" + [[ -n "${apps}" ]] || apps='[]' + + if [[ -n "${ONLY_APP}" ]]; then + apps="$(jq -nc --arg a "${ONLY_APP}" '[ $a ]')" + fi + + echo "apps=${apps}" >> "$GITHUB_OUTPUT" + echo "apps_json=${apps}" + + - name: Deploy each app (matrix via bash loop) + shell: bash + run: | + set -euo pipefail + + normalize_bool() { + case "${1:-}" in + true|True|TRUE|1) echo "true" ;; + false|False|FALSE|0) echo "false" ;; + *) echo "true" ;; + esac + } + + apps_json='${{ steps.discover.outputs.apps }}' + readarray -t apps < <(echo "${apps_json}" | jq -r '.[]') + + export MODE="rest" + export DISTROS="${DISTROS}" + export MISSING_ONLY="$(normalize_bool "${MISSING_ONLY}")" + export KEEP_STACK="$(normalize_bool "${KEEP_STACK}")" + + for app in "${apps[@]}"; do + export APP="${app}" + scripts/ci/deploy-one-app.sh + done + + - name: Show last 200 chars on failure + if: failure() + shell: bash + run: | + echo "=== DEBUG: logs ===" + ls -la logs || true + echo + + shopt -s nullglob + for f in logs/*.log; do + echo "=== tail -c 200 $f ===" + tail -c 200 "$f" || true + echo + done + + - name: Upload deploy logs + if: ${{ always() && env.ACT != 'true' }} + uses: actions/upload-artifact@v4 + with: + name: deploy-logs-rest + path: logs/ + if-no-files-found: warn + retention-days: 14 diff --git a/.github/workflows/test-deploy-workstation.yml b/.github/workflows/test-deploy-workstation.yml index 61145cb600..2a0a08d46b 100644 --- a/.github/workflows/test-deploy-workstation.yml +++ b/.github/workflows/test-deploy-workstation.yml @@ -1,10 +1,106 @@ -name: Test Infinito.Nexus Deploy (universal-rest) +name: Test Infinito.Nexus Deploy (workstation) on: workflow_call: + workflow_dispatch: + +permissions: + contents: read + packages: read + +env: + MODE: workstation + DISTROS: "arch debian ubuntu fedora centos" + ONLY_APP: "" + MISSING_ONLY: "true" + KEEP_STACK: "true" + NIX_CONFIG: | + access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} jobs: - rest: - uses: ./.github/workflows/_deploy-per-app.yml - with: - mode: rest + workstation: + name: deploy:workstation (per app, all distros) + runs-on: ubuntu-latest + timeout-minutes: 240 + + steps: + - uses: actions/checkout@v6 + + - name: Install jq + shell: bash + run: | + set -euo pipefail + sudo apt-get update + sudo apt-get install -y jq + + - name: Start stack for discovery (arch) + shell: bash + run: | + set -euo pipefail + export INFINITO_DISTRO="arch" + make up + + - name: Discover apps (JSON) + id: discover + shell: bash + run: | + set -euo pipefail + apps="$(MODE="${MODE}" scripts/ci/discover.sh)" + [[ -n "${apps}" ]] || apps='[]' + + if [[ -n "${ONLY_APP}" ]]; then + apps="$(jq -nc --arg a "${ONLY_APP}" '[ $a ]')" + fi + + echo "apps=${apps}" >> "$GITHUB_OUTPUT" + echo "apps_json=${apps}" + + - name: Deploy each app (matrix via bash loop) + shell: bash + run: | + set -euo pipefail + + normalize_bool() { + case "${1:-}" in + true|True|TRUE|1) echo "true" ;; + false|False|FALSE|0) echo "false" ;; + *) echo "true" ;; + esac + } + + apps_json='${{ steps.discover.outputs.apps }}' + readarray -t apps < <(echo "${apps_json}" | jq -r '.[]') + + export MODE="workstation" + export DISTROS="${DISTROS}" + export MISSING_ONLY="$(normalize_bool "${MISSING_ONLY}")" + export KEEP_STACK="$(normalize_bool "${KEEP_STACK}")" + + for app in "${apps[@]}"; do + export APP="${app}" + scripts/ci/deploy-one-app.sh + done + + - name: Show last 200 chars on failure + if: failure() + shell: bash + run: | + echo "=== DEBUG: logs ===" + ls -la logs || true + echo + + shopt -s nullglob + for f in logs/*.log; do + echo "=== tail -c 200 $f ===" + tail -c 200 "$f" || true + echo + done + + - name: Upload deploy logs + if: ${{ always() && env.ACT != 'true' }} + uses: actions/upload-artifact@v4 + with: + name: deploy-logs-workstation + path: logs/ + if-no-files-found: warn + retention-days: 14 diff --git a/Makefile b/Makefile index e80535513e..d487bd37b8 100644 --- a/Makefile +++ b/Makefile @@ -204,12 +204,9 @@ test-integration: build-missing test-deploy: @echo "=== act: deploy $(TEST_DEPLOY_TYPE) (all apps, distro=$(INFINITO_DISTRO)) ===" + @wf=".github/workflows/test-deploy-$(TEST_DEPLOY_TYPE).yml"; \ act workflow_dispatch \ - -W .github/workflows/_deploy-per-app.yml \ - --input mode:"$(TEST_DEPLOY_TYPE)" \ - --input distros:"$(INFINITO_DISTRO)" \ - --input missing_only:"true" \ - --input keep_stack_on_failure:"true" \ + -W "$$wf" \ --container-options "--privileged" \ --network host \ --concurrent-jobs 1 @@ -217,13 +214,11 @@ test-deploy: test-deploy-app: @if [[ -z "$(APP)" ]]; then echo "ERROR: APP is not set"; exit 1; fi @echo "=== act: deploy $(TEST_DEPLOY_TYPE) app=$(APP) distro=$(INFINITO_DISTRO) ===" + @wf=".github/workflows/test-deploy-$(TEST_DEPLOY_TYPE).yml"; \ act workflow_dispatch \ - -W .github/workflows/_deploy-per-app.yml \ - --input mode:"$(TEST_DEPLOY_TYPE)" \ - --input only_app:"$(APP)" \ - --input distros:"$(INFINITO_DISTRO)" \ - --input missing_only:"true" \ - --input keep_stack_on_failure:"true" \ + -W "$$wf" \ + --env ONLY_APP="$(APP)" \ + --env DISTROS="$(INFINITO_DISTRO)" \ --container-options "--privileged" \ --network host \ --concurrent-jobs 1 diff --git a/scripts/ci/deploy-one-app.sh b/scripts/ci/deploy-one-app.sh old mode 100644 new mode 100755 diff --git a/tests/integration/test_filters_are_defined.py b/tests/integration/test_filters_are_defined.py index e364e9873e..6ee1103137 100644 --- a/tests/integration/test_filters_are_defined.py +++ b/tests/integration/test_filters_are_defined.py @@ -134,7 +134,6 @@ def _iter_files(base: str, *, exts: Tuple[str, ...]): yield os.path.join(root, fn) - def _is_filter_plugins_dir(path: str) -> bool: return "filter_plugins" in os.path.normpath(path).split(os.sep)