|
1 | | -name: check format for React App |
2 | | - |
3 | | -on: |
4 | | - push: |
5 | | - paths: |
6 | | - - "client/**" |
7 | | - pull_request: |
8 | | - paths: |
9 | | - - "client/**" |
10 | | - |
11 | | -jobs: |
12 | | - client-check-format: |
13 | | - runs-on: ubuntu-latest |
14 | | - steps: |
15 | | - - uses: actions/checkout@v4 |
16 | | - with: |
17 | | - fetch-depth: 0 |
18 | | - |
19 | | - - name: Set up Node.js |
20 | | - uses: actions/setup-node@v4 |
21 | | - with: |
22 | | - node-version: 22 |
23 | | - |
24 | | - - name: Install dependencies (Client) |
25 | | - working-directory: ./client |
26 | | - run: npm ci |
27 | | - |
28 | | - - name: Run ESLint on changed files |
29 | | - continue-on-error: true |
30 | | - working-directory: ./client |
31 | | - run: | |
32 | | - changed_files=$(git diff --name-only --diff-filter=ACMRT HEAD^ HEAD | grep -E '\.(js|jsx|ts|tsx)$' | sed 's|^client/||' || true) |
33 | | -
|
34 | | - if [ -n "$changed_files" ]; then |
35 | | - echo "Running ESLint on changed files:" |
36 | | - echo "$changed_files" |
37 | | - npx eslint $changed_files |
38 | | - else |
39 | | - echo "No JavaScript/TypeScript files changed" |
40 | | - fi |
41 | | -
|
42 | | - client-run-tests: |
43 | | - runs-on: ubuntu-latest |
44 | | - needs: client-check-format |
45 | | - steps: |
46 | | - - uses: actions/checkout@v4 |
47 | | - |
48 | | - - name: Set up Node.js |
49 | | - uses: actions/setup-node@v4 |
50 | | - with: |
51 | | - node-version: 22 |
52 | | - |
53 | | - - name: Install dependencies |
54 | | - working-directory: ./client |
55 | | - run: npm ci |
56 | | - |
57 | | - - name: Run tests |
58 | | - working-directory: ./client |
59 | | - run: npm test |
60 | | - |
61 | | - client-docker-build-push: |
62 | | - if: github.ref == 'refs/heads/main' && github.event_name == 'push' |
63 | | - runs-on: ubuntu-latest |
64 | | - needs: [client-check-format, client-run-tests] |
65 | | - permissions: |
66 | | - packages: write |
67 | | - contents: read |
68 | | - steps: |
69 | | - - uses: actions/checkout@v4 |
70 | | - |
71 | | - - name: Set up Docker Buildx |
72 | | - uses: docker/setup-buildx-action@v3 |
73 | | - |
74 | | - - name: Log in to GitHub Container Registry |
75 | | - uses: docker/login-action@v3 |
76 | | - with: |
77 | | - registry: ghcr.io |
78 | | - username: ${{ github.actor }} |
79 | | - password: ${{ secrets.GITHUB_TOKEN }} |
80 | | - |
81 | | - - name: Build and push Docker image |
82 | | - uses: docker/build-push-action@v5 |
83 | | - with: |
84 | | - context: ./client |
85 | | - file: ./client/Dockerfile |
86 | | - push: true |
87 | | - tags: | |
88 | | - ghcr.io/aet-devops25/team-cache-me-if-you-can/client:latest |
89 | | - ghcr.io/aet-devops25/team-cache-me-if-you-can/client:${{ github.sha }} |
90 | | - labels: | |
91 | | - org.opencontainers.image.source=https://github.com/${{ github.repository }} |
92 | | - org.opencontainers.image.revision=${{ github.sha }} |
93 | | -
|
94 | | - client-deploy: |
95 | | - name: Deploy to Kubernetes |
96 | | - runs-on: ubuntu-latest |
97 | | - needs: [client-check-format, client-run-tests, client-docker-build-push] |
98 | | - if: github.ref == 'refs/heads/main' && github.event_name == 'push' |
99 | | - |
100 | | - steps: |
101 | | - - name: Checkout Code |
102 | | - uses: actions/checkout@v4 |
103 | | - |
104 | | - - name: Set up Terraform |
105 | | - uses: hashicorp/setup-terraform@v3 |
106 | | - |
107 | | - - name: Set up Kubernetes tools |
108 | | - uses: azure/setup-kubectl@v3 |
109 | | - |
110 | | - - name: Configure kubeconfig |
111 | | - run: | |
112 | | - mkdir -p ~/.kube |
113 | | - echo "${{ secrets.KUBE_CONFIG_DATA }}" > ~/.kube/config |
114 | | - chmod 600 ~/.kube/config |
115 | | -
|
116 | | - - name: Terraform Init |
117 | | - run: terraform init |
118 | | - working-directory: ./client/terraform |
119 | | - |
120 | | - - name: Terraform Plan |
121 | | - run: terraform plan -var="redeploy_id=${{ github.sha }}" |
122 | | - working-directory: ./client/terraform |
123 | | - |
124 | | - - name: Terraform Apply |
125 | | - run: terraform apply -auto-approve -var="redeploy_id=${{ github.sha }}" |
126 | | - working-directory: ./client/terraform |
127 | | - env: |
128 | | - KUBECONFIG: $HOME/.kube/config |
| 1 | +name: Client Code Quality & Testing |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: ['**'] |
| 6 | + paths: |
| 7 | + - "client/**" |
| 8 | + pull_request: |
| 9 | + branches: ['**'] |
| 10 | + paths: |
| 11 | + - "client/**" |
| 12 | + |
| 13 | +jobs: |
| 14 | + client-check-format: |
| 15 | + name: Code Quality Check |
| 16 | + runs-on: ubuntu-latest |
| 17 | + steps: |
| 18 | + - uses: actions/checkout@v4 |
| 19 | + with: |
| 20 | + fetch-depth: 0 |
| 21 | + |
| 22 | + - name: Set up Node.js |
| 23 | + uses: actions/setup-node@v4 |
| 24 | + with: |
| 25 | + node-version: 22 |
| 26 | + |
| 27 | + - name: Install dependencies (Client) |
| 28 | + working-directory: ./client |
| 29 | + run: npm ci |
| 30 | + |
| 31 | + - name: Run ESLint on changed files |
| 32 | + continue-on-error: true |
| 33 | + working-directory: ./client |
| 34 | + run: | |
| 35 | + changed_files=$(git diff --name-only --diff-filter=ACMRT HEAD^ HEAD | grep -E '\.(js|jsx|ts|tsx)$' | sed 's|^client/||' || true) |
| 36 | +
|
| 37 | + if [ -n "$changed_files" ]; then |
| 38 | + echo "Running ESLint on changed files:" |
| 39 | + echo "$changed_files" |
| 40 | + npx eslint $changed_files |
| 41 | + else |
| 42 | + echo "No JavaScript/TypeScript files changed" |
| 43 | + fi |
| 44 | +
|
| 45 | + - name: Check TypeScript compilation |
| 46 | + working-directory: ./client |
| 47 | + run: npx tsc --noEmit |
| 48 | + |
| 49 | + client-run-tests: |
| 50 | + name: Run Tests |
| 51 | + runs-on: ubuntu-latest |
| 52 | + needs: client-check-format |
| 53 | + steps: |
| 54 | + - uses: actions/checkout@v4 |
| 55 | + |
| 56 | + - name: Set up Node.js |
| 57 | + uses: actions/setup-node@v4 |
| 58 | + with: |
| 59 | + node-version: 22 |
| 60 | + |
| 61 | + - name: Install dependencies |
| 62 | + working-directory: ./client |
| 63 | + run: npm ci |
| 64 | + |
| 65 | + - name: Run tests |
| 66 | + working-directory: ./client |
| 67 | + run: npm test |
| 68 | + |
| 69 | + - name: Run build test |
| 70 | + working-directory: ./client |
| 71 | + run: npm run build |
| 72 | + |
| 73 | + deployment-notice: |
| 74 | + name: Deployment Information |
| 75 | + runs-on: ubuntu-latest |
| 76 | + needs: [client-check-format, client-run-tests] |
| 77 | + if: github.event_name == 'pull_request' || (github.event_name == 'push' && github.ref == 'refs/heads/main') |
| 78 | + steps: |
| 79 | + - name: Show deployment info |
| 80 | + run: | |
| 81 | + echo "ℹ️ **Client Deployment Information**" |
| 82 | + echo "" |
| 83 | + if [ "${{ github.event_name }}" = "pull_request" ]; then |
| 84 | + echo "🔄 **Pull Request detected**" |
| 85 | + echo "- Client will be deployed to **pre-prod** environment" |
| 86 | + echo "- Deployment handled by unified server-ci-cd.yml pipeline" |
| 87 | + echo "- URL: https://cache-me-if-you-can-client-pre-prod.team-cache-me-if-you-can.student.k8s.aet.cit.tum.de" |
| 88 | + elif [ "${{ github.ref }}" = "refs/heads/main" ]; then |
| 89 | + echo "🚀 **Main branch push detected**" |
| 90 | + echo "- Client will be deployed to **prod** environment" |
| 91 | + echo "- Deployment handled by unified server-ci-cd.yml pipeline" |
| 92 | + echo "- URL: https://cache-me-if-you-can-client-prod.team-cache-me-if-you-can.student.k8s.aet.cit.tum.de" |
| 93 | + fi |
0 commit comments