|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: [main, AION] |
| 6 | + push: |
| 7 | + branches: [main, AION] |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: read |
| 11 | + |
| 12 | +jobs: |
| 13 | + lint: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + steps: |
| 16 | + - uses: actions/checkout@v4 |
| 17 | + - uses: actions/setup-python@v5 |
| 18 | + with: |
| 19 | + python-version: '3.11' |
| 20 | + cache: 'pip' |
| 21 | + - uses: actions/setup-node@v4 |
| 22 | + with: |
| 23 | + node-version: '20' |
| 24 | + cache: 'npm' |
| 25 | + cache-dependency-path: console/package-lock.json |
| 26 | + - uses: dtolnay/rust-toolchain@stable |
| 27 | + - uses: Swatinem/rust-cache@v2 |
| 28 | + - name: Install python deps |
| 29 | + run: | |
| 30 | + python -m pip install --upgrade pip |
| 31 | + pip install ruff bandit pytest |
| 32 | + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi |
| 33 | + - name: Python lint |
| 34 | + run: ruff check . |
| 35 | + - name: Rust lint |
| 36 | + run: cargo clippy --manifest-path rust-runtime/Cargo.toml --all-targets -- -D warnings |
| 37 | + - name: Conventional commits (PR title) |
| 38 | + if: github.event_name == 'pull_request' |
| 39 | + run: | |
| 40 | + echo "${{ github.event.pull_request.title }}" | grep -E '^(feat|fix|chore|docs|refactor|test|ci|perf|build|revert)(\(.+\))?!?: .+' |
| 41 | +
|
| 42 | + test: |
| 43 | + runs-on: ubuntu-latest |
| 44 | + needs: lint |
| 45 | + steps: |
| 46 | + - uses: actions/checkout@v4 |
| 47 | + - uses: actions/setup-python@v5 |
| 48 | + with: |
| 49 | + python-version: '3.11' |
| 50 | + - uses: dtolnay/rust-toolchain@stable |
| 51 | + - name: Install test deps |
| 52 | + run: | |
| 53 | + python -m pip install --upgrade pip |
| 54 | + pip install pytest |
| 55 | + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi |
| 56 | + - name: Unit and architecture tests |
| 57 | + run: | |
| 58 | + if [ -d os ] || [ -d aion ]; then |
| 59 | + pytest -q tests/ |
| 60 | + else |
| 61 | + pytest -q tests/architecture |
| 62 | + fi |
| 63 | + - name: Rust tests |
| 64 | + run: cargo test --manifest-path rust-runtime/Cargo.toml --all-targets |
| 65 | + |
| 66 | + integration: |
| 67 | + runs-on: ubuntu-latest |
| 68 | + needs: test |
| 69 | + services: |
| 70 | + redis: |
| 71 | + image: redis:7 |
| 72 | + ports: ['6379:6379'] |
| 73 | + steps: |
| 74 | + - uses: actions/checkout@v4 |
| 75 | + - name: Integration test placeholder |
| 76 | + run: | |
| 77 | + if [ -d tests/integration ]; then |
| 78 | + pytest -q tests/integration |
| 79 | + else |
| 80 | + echo "No integration tests yet" |
| 81 | + fi |
| 82 | +
|
| 83 | + security: |
| 84 | + runs-on: ubuntu-latest |
| 85 | + needs: lint |
| 86 | + permissions: |
| 87 | + security-events: write |
| 88 | + contents: read |
| 89 | + steps: |
| 90 | + - uses: actions/checkout@v4 |
| 91 | + - uses: actions/setup-python@v5 |
| 92 | + with: |
| 93 | + python-version: '3.11' |
| 94 | + - uses: dtolnay/rust-toolchain@stable |
| 95 | + - name: Bandit |
| 96 | + run: | |
| 97 | + python -m pip install --upgrade pip |
| 98 | + pip install bandit |
| 99 | + bandit -r . -x tests -s B101,B105 |
| 100 | + - name: Cargo audit |
| 101 | + run: | |
| 102 | + cargo install cargo-audit --locked |
| 103 | + cargo audit --manifest-path rust-runtime/Cargo.toml |
| 104 | + - name: Trivy filesystem scan |
| 105 | + uses: aquasecurity/trivy-action@0.24.0 |
| 106 | + with: |
| 107 | + scan-type: fs |
| 108 | + scan-ref: . |
| 109 | + |
| 110 | + docker: |
| 111 | + runs-on: ubuntu-latest |
| 112 | + needs: [test, security] |
| 113 | + strategy: |
| 114 | + matrix: |
| 115 | + platform: [linux/amd64, linux/arm64] |
| 116 | + steps: |
| 117 | + - uses: actions/checkout@v4 |
| 118 | + - uses: docker/setup-qemu-action@v3 |
| 119 | + - uses: docker/setup-buildx-action@v3 |
| 120 | + - name: Build compose image |
| 121 | + uses: docker/build-push-action@v6 |
| 122 | + with: |
| 123 | + context: . |
| 124 | + file: Dockerfile |
| 125 | + push: false |
| 126 | + platforms: ${{ matrix.platform }} |
| 127 | + tags: omertaos:${{ github.sha }} |
| 128 | + |
| 129 | + sbom: |
| 130 | + runs-on: ubuntu-latest |
| 131 | + needs: docker |
| 132 | + steps: |
| 133 | + - uses: actions/checkout@v4 |
| 134 | + - name: Generate SBOM |
| 135 | + uses: anchore/sbom-action@v0 |
| 136 | + with: |
| 137 | + path: . |
| 138 | + format: spdx-json |
| 139 | + output-file: sbom.spdx.json |
| 140 | + - uses: actions/upload-artifact@v4 |
| 141 | + with: |
| 142 | + name: sbom |
| 143 | + path: sbom.spdx.json |
0 commit comments