feature/kube: update dependencies #189
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Test features | |
| on: | |
| pull_request: | |
| jobs: | |
| setup: | |
| name: Setup | |
| permissions: | |
| contents: read | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v5 | |
| with: { fetch-depth: 0 } | |
| - name: Fetch base and head | |
| run: | | |
| git fetch origin ${{ github.base_ref }}:${{ github.base_ref }} | |
| git fetch origin ${{ github.head_ref }}:${{ github.head_ref }} | |
| - name: Load config | |
| id: config | |
| env: | |
| REGISTRY: ${{ vars.CONTAINER_REGISTRY }} | |
| NAMESPACE: ${{ vars.CONTAINER_NAMESPACE_FEATURE }} | |
| BASE: ${{ github.base_ref }} | |
| HEAD: ${{ github.head_ref }} | |
| run: | | |
| python3 <<EOF >> $GITHUB_OUTPUT | |
| from collections import deque, defaultdict | |
| import json | |
| from os import environ as env | |
| from pathlib import Path | |
| import re | |
| import subprocess | |
| features = [ | |
| feature | |
| for feature in Path("features/src").iterdir() | |
| if feature.is_dir() and (feature / "devcontainer-feature.json").is_file() | |
| ] | |
| tree = defaultdict(set) | |
| for feature in features: | |
| manifest = json.loads((feature / "devcontainer-feature.json").read_text()) | |
| name = manifest["name"] | |
| deps = [ | |
| g["dep"] | |
| for d in manifest.get("dependsOn", {}).keys() | |
| if (g := re.search(f"^{env['REGISTRY']}/{env['NAMESPACE']}/(?P<dep>[^:]+):", d)) | |
| ] | |
| for d in deps: | |
| tree[d].add(name) | |
| cmd = ["git", "diff", "--name-only", f"{env['BASE']}...{env['HEAD']}"] | |
| changes = subprocess.check_output(cmd).decode('utf-8').strip().split("\n") | |
| q = deque(set([ | |
| g["feature"] | |
| for c in changes | |
| if (g := re.search("^features/(src|test)/(?P<feature>[^/]+)/", c)) | |
| ])) | |
| features = [] | |
| while q: | |
| f = q.popleft() | |
| features.append(f) | |
| q.extend(tree[f]) | |
| print(f"features={json.dumps(features)}") | |
| EOF | |
| outputs: | |
| features: ${{ steps.config.outputs.features }} | |
| test: | |
| name: Test feature | |
| needs: setup | |
| if: ${{ needs.setup.outputs.features != '' && toJson(fromJson(needs.setup.outputs.features)) != '[]' }} | |
| strategy: | |
| matrix: | |
| feature: ${{ fromJSON(needs.setup.outputs.features) }} | |
| uses: ./.github/workflows/test-feature.yaml | |
| with: | |
| feature: ${{ matrix.feature }} | |
| done: | |
| name: Test features | |
| needs: test | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: No op | |
| run: exit 0 |