|
1 | 1 | name: Test PHP API Stack |
2 | 2 |
|
3 | 3 | on: |
4 | | - push: |
5 | | - branches: [main, develop] |
6 | | - pull_request: |
7 | | - branches: [main] |
8 | | - workflow_dispatch: |
| 4 | + push: |
| 5 | + branches: [main, develop] |
| 6 | + pull_request: |
| 7 | + branches: [main] |
| 8 | + workflow_dispatch: |
9 | 9 |
|
10 | 10 | jobs: |
11 | | - lint: |
12 | | - name: Lint Dockerfile |
13 | | - runs-on: ubuntu-latest |
14 | | - steps: |
15 | | - - uses: actions/checkout@v3 |
16 | | - |
17 | | - - name: Run hadolint |
18 | | - run: make lint |
19 | | - |
20 | | - build: |
21 | | - name: Build Image |
22 | | - needs: lint |
23 | | - runs-on: ubuntu-latest |
24 | | - steps: |
25 | | - - uses: actions/checkout@v3 |
26 | | - |
27 | | - - name: Build production image |
28 | | - run: make build |
29 | | - |
30 | | - - name: Quick component tests |
31 | | - run: make test-quick |
32 | | - |
33 | | - - name: Save image |
34 | | - run: docker save kariricode/php-api-stack:latest | gzip > image.tar.gz |
35 | | - |
36 | | - - name: Upload artifact |
37 | | - uses: actions/upload-artifact@v3 |
38 | | - with: |
39 | | - name: docker-image |
40 | | - path: image.tar.gz |
41 | | - |
42 | | - test: |
43 | | - name: Run Tests |
44 | | - needs: build |
45 | | - runs-on: ubuntu-latest |
46 | | - steps: |
47 | | - - uses: actions/checkout@v3 |
48 | | - |
49 | | - - name: Download image |
50 | | - uses: actions/download-artifact@v3 |
51 | | - with: |
52 | | - name: docker-image |
53 | | - |
54 | | - - name: Load image |
55 | | - run: docker load < image.tar.gz |
56 | | - |
57 | | - - name: Run comprehensive tests |
58 | | - run: make test |
59 | | - |
60 | | - - name: Run integration tests |
61 | | - run: | |
62 | | - make run |
63 | | - sleep 10 |
64 | | - curl -f http://localhost:8080 |
65 | | - curl -f http://localhost:8080/health |
66 | | - make stop |
67 | | -
|
68 | | - test-health: |
69 | | - name: Test Health Checks |
70 | | - needs: build |
71 | | - runs-on: ubuntu-latest |
72 | | - steps: |
73 | | - - uses: actions/checkout@v3 |
74 | | - |
75 | | - - name: Download image |
76 | | - uses: actions/download-artifact@v3 |
77 | | - with: |
78 | | - name: docker-image |
79 | | - |
80 | | - - name: Load image |
81 | | - run: docker load < image.tar.gz |
82 | | - |
83 | | - - name: Build test image |
84 | | - run: make build-test-image |
85 | | - |
86 | | - - name: Run test container |
87 | | - run: make run-test |
88 | | - |
89 | | - - name: Test comprehensive health check |
90 | | - run: | |
91 | | - sleep 10 |
92 | | - make test-health |
93 | | - curl -s http://localhost:8080/health.php | jq '.status' | grep -q "healthy" |
94 | | -
|
95 | | - - name: Stop test container |
96 | | - run: make stop-test |
97 | | - |
98 | | - security: |
99 | | - name: Security Scan |
100 | | - needs: build |
101 | | - runs-on: ubuntu-latest |
102 | | - steps: |
103 | | - - uses: actions/checkout@v3 |
104 | | - |
105 | | - - name: Download image |
106 | | - uses: actions/download-artifact@v3 |
107 | | - with: |
108 | | - name: docker-image |
109 | | - |
110 | | - - name: Load image |
111 | | - run: docker load < image.tar.gz |
112 | | - |
113 | | - - name: Run Trivy scan |
114 | | - uses: aquasecurity/trivy-action@master |
115 | | - with: |
116 | | - image-ref: "kariricode/php-api-stack:latest" |
117 | | - format: "sarif" |
118 | | - output: "trivy-results.sarif" |
119 | | - severity: "CRITICAL,HIGH" |
120 | | - |
121 | | - - name: Upload Trivy results |
122 | | - uses: github/codeql-action/upload-sarif@v2 |
123 | | - with: |
124 | | - sarif_file: "trivy-results.sarif" |
| 11 | + lint: |
| 12 | + name: Lint Dockerfile |
| 13 | + runs-on: ubuntu-latest |
| 14 | + steps: |
| 15 | + - uses: actions/checkout@v3 |
| 16 | + |
| 17 | + - name: Run hadolint |
| 18 | + run: make lint |
| 19 | + |
| 20 | + build: |
| 21 | + name: Build Image |
| 22 | + needs: lint |
| 23 | + runs-on: ubuntu-latest |
| 24 | + steps: |
| 25 | + - uses: actions/checkout@v3 |
| 26 | + |
| 27 | + - name: Build production image |
| 28 | + run: make build |
| 29 | + |
| 30 | + - name: Quick component tests |
| 31 | + run: make test-quick |
| 32 | + |
| 33 | + - name: Save image |
| 34 | + run: docker save kariricode/php-api-stack:latest | gzip > image.tar.gz |
| 35 | + |
| 36 | + - name: Upload artifact |
| 37 | + uses: actions/upload-artifact@v3 |
| 38 | + with: |
| 39 | + name: docker-image |
| 40 | + path: image.tar.gz |
| 41 | + |
| 42 | + test: |
| 43 | + name: Run Tests |
| 44 | + needs: build |
| 45 | + runs-on: ubuntu-latest |
| 46 | + steps: |
| 47 | + - uses: actions/checkout@v3 |
| 48 | + |
| 49 | + - name: Download image |
| 50 | + uses: actions/download-artifact@v3 |
| 51 | + with: |
| 52 | + name: docker-image |
| 53 | + |
| 54 | + - name: Load image |
| 55 | + run: docker load < image.tar.gz |
| 56 | + |
| 57 | + - name: Run comprehensive tests |
| 58 | + run: make test |
| 59 | + |
| 60 | + - name: Run integration tests |
| 61 | + run: | |
| 62 | + make run |
| 63 | + sleep 10 |
| 64 | + curl -f http://localhost:8080 |
| 65 | + curl -f http://localhost:8080/health |
| 66 | + make stop |
| 67 | +
|
| 68 | + test-health: |
| 69 | + name: Test Health Checks |
| 70 | + needs: build |
| 71 | + runs-on: ubuntu-latest |
| 72 | + steps: |
| 73 | + - uses: actions/checkout@v3 |
| 74 | + |
| 75 | + - name: Download image |
| 76 | + uses: actions/download-artifact@v3 |
| 77 | + with: |
| 78 | + name: docker-image |
| 79 | + |
| 80 | + - name: Load image |
| 81 | + run: docker load < image.tar.gz |
| 82 | + |
| 83 | + - name: Build test image |
| 84 | + run: make build-test-image |
| 85 | + |
| 86 | + - name: Run test container |
| 87 | + run: make run-test |
| 88 | + |
| 89 | + - name: Test comprehensive health check |
| 90 | + run: | |
| 91 | + sleep 10 |
| 92 | + make test-health |
| 93 | + curl -s http://localhost:8080/health.php | jq '.status' | grep -q "healthy" |
| 94 | +
|
| 95 | + - name: Stop test container |
| 96 | + run: make stop-test |
| 97 | + |
| 98 | + security: |
| 99 | + name: Security Scan |
| 100 | + needs: build |
| 101 | + runs-on: ubuntu-latest |
| 102 | + steps: |
| 103 | + - uses: actions/checkout@v3 |
| 104 | + |
| 105 | + - name: Download image |
| 106 | + uses: actions/download-artifact@v3 |
| 107 | + with: |
| 108 | + name: docker-image |
| 109 | + |
| 110 | + - name: Load image |
| 111 | + run: docker load < image.tar.gz |
| 112 | + |
| 113 | + - name: Run Trivy scan |
| 114 | + uses: aquasecurity/trivy-action@master |
| 115 | + with: |
| 116 | + image-ref: "kariricode/php-api-stack:latest" |
| 117 | + format: "sarif" |
| 118 | + output: "trivy-results.sarif" |
| 119 | + severity: "CRITICAL,HIGH" |
| 120 | + |
| 121 | + - name: Upload Trivy results |
| 122 | + uses: github/codeql-action/upload-sarif@v2 |
| 123 | + with: |
| 124 | + sarif_file: "trivy-results.sarif" |
0 commit comments