Skip to content

Commit 6c7a0af

Browse files
committed
Refactor OIDC code, fix linter issues, add documentation
1 parent 19458af commit 6c7a0af

File tree

178 files changed

+14528
-1696
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

178 files changed

+14528
-1696
lines changed

.github/workflows/go.yml

Lines changed: 85 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@ on:
1212
- development
1313
paths-ignore:
1414
- 'docs/**' # Ignore changes to docs folder
15+
- '**/*.md'
1516
# Run on pull requests to main or development branches
1617
pull_request:
1718
branches:
1819
- main
1920
- development
2021
paths-ignore:
21-
- 'docs/**' # Ignore changes to docs folder
22+
- 'docs/**'# Ignore changes to docs folder
23+
- '**/*.md'
2224

2325
# Define the jobs that this workflow will run
2426
jobs:
@@ -29,15 +31,15 @@ jobs:
2931
# Define a matrix strategy to test against multiple Go versions
3032
strategy:
3133
matrix:
32-
go-version: ['1.24','1.23', '1.22']
34+
go-version: ['1.25','1.24', '1.23']
3335
# Continue with other jobs if one version fails
3436
fail-fast: false
3537

3638
# Define service containers that tests depend on
3739
services:
3840
# Kafka service
3941
kafka:
40-
image: bitnami/kafka:3.4
42+
image: bitnami/kafka:3.4.1
4143
ports:
4244
- "9092:9092"
4345
env:
@@ -120,7 +122,7 @@ jobs:
120122
runs-on: ubuntu-latest
121123
strategy:
122124
matrix:
123-
go-version: ['1.24','1.23', '1.22']
125+
go-version: ['1.25','1.24', '1.23']
124126
fail-fast: false
125127

126128
steps:
@@ -146,15 +148,39 @@ jobs:
146148
with:
147149
timeout_minutes: 5
148150
max_attempts: 2
151+
retry_on: error
149152
command: |
150153
export APP_ENV=test
151-
# Run tests with coverage for root gofr package only
152-
go test -v -short -covermode=atomic -coverpkg=./pkg/gofr -coverprofile=gofr_only.cov ./pkg/gofr
153-
# Run tests for all sub-packages under gofr
154-
go test -v -covermode=atomic -coverpkg=./pkg/gofr -coverprofile=submodules.cov ./pkg/gofr/...
154+
155+
# Run tests for root gofr package
156+
go test -v -short -covermode=atomic \
157+
-coverpkg=./pkg/gofr -coverprofile=gofr_only.cov ./pkg/gofr
158+
exit_code=$?
159+
if [ $exit_code -eq 2 ]; then
160+
echo "::error::Panic detected in root gofr package tests"
161+
exit 2
162+
elif [ $exit_code -ne 0 ]; then
163+
echo "::error::Root gofr package tests failed"
164+
exit $exit_code
165+
fi
166+
167+
# Run tests for sub-packages
168+
go test -v -covermode=atomic \
169+
-coverpkg=./pkg/gofr -coverprofile=submodules.cov ./pkg/gofr/...
170+
exit_code=$?
171+
if [ $exit_code -eq 2 ]; then
172+
echo "::error::Panic detected in gofr sub-packages tests"
173+
exit 2
174+
elif [ $exit_code -ne 0 ]; then
175+
echo "::error::Gofr sub-packages tests failed"
176+
exit $exit_code
177+
fi
178+
155179
# Combine coverage profiles
156180
echo "mode: atomic" > profile.cov
157181
grep -h -v "mode:" gofr_only.cov submodules.cov | grep -v '/mock_' >> profile.cov
182+
183+
# Show coverage summary
158184
go tool cover -func profile.cov
159185
160186
# Upload coverage report for the 1.24 Go version only
@@ -208,7 +234,7 @@ jobs:
208234
runs-on: ubuntu-latest
209235
strategy:
210236
matrix:
211-
go-version: ['1.24','1.23', '1.22']
237+
go-version: ['1.25','1.24', '1.23']
212238
fail-fast: false
213239

214240
steps:
@@ -264,7 +290,7 @@ jobs:
264290
265291
# Copy coverage file to the coverage_reports directory
266292
cp ${module_name}.cov ../../../coverage_reports/
267-
293+
268294
cd -
269295
'
270296
@@ -275,45 +301,52 @@ jobs:
275301
name: submodule-coverage-reports
276302
path: coverage_reports/*.cov
277303

278-
# Job for uploading coverage to external services (CodeClimate)
279-
# upload_coverage:
280-
# name: Upload Coverage📊
281-
# runs-on: ubuntu-latest
282-
# # This job only needs example and pkg test results, not submodules
283-
# needs: [Example-Unit-Testing, PKG-Unit-Testing]
284-
# # Only run this job on pushes to the development branch
285-
# if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/development'}}
286-
# steps:
287-
# - name: Check out code into the Go module directory
288-
# uses: actions/checkout@v5
289-
#
290-
# # Download coverage artifacts
291-
# - name: Download Coverage Report
292-
# uses: actions/download-artifact@v5
293-
# with:
294-
# path: artifacts
295-
#
296-
# # Merge coverage from example and pkg tests only
297-
# - name: Merge Coverage Files
298-
# working-directory: artifacts
299-
# run: |
300-
# echo "mode: set" > merged_profile.cov
301-
# tail -n +2 ./Example-Test-Report/profile.cov >> merged_profile.cov
302-
# tail -n +2 ./PKG-Coverage-Report/profile.cov >> merged_profile.cov
303-
#
304-
# # Generate and print total coverage percentage
305-
# echo "Total Coverage:"
306-
# go tool cover -func=merged_profile.cov | tail -n 1
307-
# shell: bash
308-
#
309-
# # Upload merged coverage to CodeClimate for analysis
310-
# - name: Upload
311-
# uses: paambaati/[email protected]
312-
# env:
313-
# CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
314-
# with:
315-
# coverageLocations: artifacts/merged_profile.cov:gocov
316-
# prefix: gofr.dev
304+
# Job for uploading coverage to external services (qlty.sh)
305+
upload_coverage:
306+
name: Upload Coverage📊
307+
runs-on: ubuntu-latest
308+
env:
309+
QLTY_TOKEN: ${{ secrets.QLTY_TOKEN }}
310+
QLTY_COVERAGE_TOKEN: ${{ secrets.QLTY_TOKEN }}
311+
312+
# This job only needs example and pkg test results, not submodules
313+
needs: [Example-Unit-Testing, PKG-Unit-Testing]
314+
# Only run this job on pushes to the development branch
315+
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/development'}}
316+
steps:
317+
- name: Check out code into the Go module directory
318+
uses: actions/checkout@v5
319+
320+
- name: Install qlty CLI
321+
run: |
322+
curl https://qlty.sh | sh
323+
echo "$HOME/.qlty/bin" >> $GITHUB_PATH
324+
325+
# Download coverage artifacts
326+
- name: Download Coverage Report
327+
uses: actions/download-artifact@v5
328+
with:
329+
path: artifacts
330+
331+
# Merge coverage from example and pkg tests only
332+
- name: Merge Coverage Files
333+
working-directory: artifacts
334+
run: |
335+
echo "mode: set" > merged_profile.cov
336+
tail -n +2 ./Example-Test-Report/profile.cov >> merged_profile.cov
337+
tail -n +2 ./PKG-Coverage-Report/profile.cov >> merged_profile.cov
338+
339+
# Generate and print total coverage percentage
340+
echo "Total Coverage:"
341+
go tool cover -func=merged_profile.cov | tail -n 1
342+
shell: bash
343+
344+
# Upload merged coverage to CodeClimate for analysis
345+
- name: Upload
346+
working-directory: artifacts
347+
run: qlty coverage publish merged_profile.cov --format=coverprofile --strip-prefix="gofr.dev/" --add-prefix="${GITHUB_WORKSPACE}/"
348+
env:
349+
QLTY_TOKEN: ${{ secrets.QLTY_TOKEN }}
317350

318351
# Job for code quality checks
319352
code_quality:
@@ -326,13 +359,13 @@ jobs:
326359
- name: Set up Go environment
327360
uses: actions/setup-go@v5
328361
with:
329-
go-version: '1.24'
362+
go-version: '1.25'
330363
cache: false
331364

332365
# Install the linting tool
333366
- name: Install golangci-lint
334367
run: |
335-
go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.1
368+
go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.4.0
336369
337370
- name: Get dependencies
338371
run: |
@@ -373,7 +406,7 @@ jobs:
373406
- name: Set up Go environment
374407
uses: actions/setup-go@v5
375408
with:
376-
go-version: 1.24
409+
go-version: 1.25
377410

378411
# Check file naming conventions using ls-lint
379412
- name: Check for file names errors

.github/workflows/typos.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ jobs:
1111
- name: Checkout Code
1212
uses: actions/checkout@v5
1313
- name: typos-action
14-
uses: crate-ci/typos@v1.35.3
14+
uses: crate-ci/typos@v1.36.2

.github/workflows/website.yml renamed to .github/workflows/website-prod.yml

Lines changed: 4 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ on:
66
push:
77
tags:
88
- "v*.*.*"
9-
branches:
10-
- main
11-
- development
9+
1210
env:
1311
APP_NAME: gofr-website
1412
WEBSITE_REGISTRY: ghcr.io
@@ -39,7 +37,7 @@ jobs:
3937
with:
4038
registry: us-central1-docker.pkg.dev
4139
username: _json_key
42-
password: ${{ secrets.deploy_key }}
40+
password: ${{ secrets.GOFR_WEBSITE_GOFR_DEV_DEPLOYMENT_KEY }}
4341

4442
- name: Log in to the GitHub Container registry
4543
uses: docker/login-action@v3
@@ -74,35 +72,7 @@ jobs:
7472
- id: output-image
7573
run: echo "image=`echo us-central1-docker.pkg.dev/${{ env.GAR_PROJECT }}/${{ env.GAR_REGISTRY }}/${{ env.APP_NAME }}:${{ env.TAG }}`" >> "$GITHUB_OUTPUT"
7674

77-
deployment_stage:
78-
runs-on: ubuntu-latest
79-
if: ${{ github.ref == 'refs/heads/development' }}
80-
name: 🚀 Deploy-Stage
81-
needs: dockerize
82-
container:
83-
image: ghcr.io/zopsmart/gha-images:deployments-0.1.3
84-
options: --rm
85-
env:
86-
image: ${{needs.dockerize.outputs.image}}
87-
88-
steps:
89-
- name: Checkout Code
90-
uses: actions/checkout@v5
91-
92-
- name: Authorize to GCP service account
93-
uses: google-github-actions/auth@v2
94-
with:
95-
credentials_json: ${{ secrets.deploy_key }}
96-
97-
- name: Set GCloud Project and Fetch Cluster Credentials
98-
run: gcloud container clusters get-credentials ${{ env.CLUSTER_NAME }} --region=us-central1 --project=${{ env.CLUSTER_PROJECT }}
99-
100-
- name: Update Deployment Image
101-
run: kubectl set image deployment/${{ env.APP_NAME }} ${{ env.APP_NAME }}=${{ env.image }} --namespace ${{ env.NAMESPACE_STAGE }}
102-
103-
10475
deployment:
105-
if: ${{ startsWith(github.ref, 'refs/tags/v')}}
10676
runs-on: ubuntu-latest
10777
name: 🚀 Deploy-Prod
10878
needs: dockerize
@@ -117,9 +87,9 @@ jobs:
11787
uses: actions/checkout@v5
11888

11989
- name: Authorize to GCP service account
120-
uses: google-github-actions/auth@v2
90+
uses: google-github-actions/auth@v3
12191
with:
122-
credentials_json: ${{ secrets.deploy_key }}
92+
credentials_json: ${{ secrets.GOFR_WEBSITE_GOFR_DEV_DEPLOYMENT_KEY }}
12393

12494
- name: Set GCloud Project and Fetch Cluster Credentials
12595
run: gcloud container clusters get-credentials ${{ env.CLUSTER_NAME }} --region=us-central1 --project=${{ env.CLUSTER_PROJECT }}
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
name: Build and Deploy Website To Stage
2+
permissions:
3+
contents: read
4+
5+
on:
6+
push:
7+
branches:
8+
- development
9+
10+
env:
11+
APP_NAME: gofr-website
12+
WEBSITE_REGISTRY: ghcr.io
13+
GAR_PROJECT: raramuri-tech
14+
GAR_REGISTRY: kops-dev
15+
CLUSTER_NAME: raramuri-tech
16+
CLUSTER_PROJECT: raramuri-tech
17+
NAMESPACE: gofr-dev
18+
NAMESPACE_STAGE: gofr-dev-stg
19+
20+
jobs:
21+
dockerize:
22+
permissions:
23+
contents: read
24+
packages: write
25+
runs-on: ubuntu-latest
26+
outputs:
27+
image: ${{ steps.output-image.outputs.image }}
28+
name: 🐳 Dockerize
29+
steps:
30+
- name: Checkout Code
31+
uses: actions/checkout@v5
32+
33+
- name: Set up Docker Buildx
34+
uses: docker/setup-buildx-action@v3
35+
36+
- name: Login to GAR
37+
uses: docker/login-action@v3
38+
with:
39+
registry: us-central1-docker.pkg.dev
40+
username: _json_key
41+
password: ${{ secrets.GOFR_WEBSITE_GOFR_DEV_STG_DEPLOYMENT_KEY }}
42+
43+
- name: Log in to the GitHub Container registry
44+
uses: docker/login-action@v3
45+
with:
46+
registry: ${{ env.WEBSITE_REGISTRY }}
47+
username: ${{ github.actor }}
48+
password: ${{ secrets.GITHUB_TOKEN }}
49+
50+
- name: Download UI Image
51+
run: |
52+
docker pull ${{ env.WEBSITE_REGISTRY }}/gofr-dev/website:latest
53+
54+
- name: Determine Image Tag
55+
id: determine-tag
56+
run: |
57+
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
58+
TAG=${GITHUB_REF#refs/tags/}
59+
else
60+
TAG=${{ github.sha }}
61+
fi
62+
echo "TAG=$TAG" >> $GITHUB_ENV
63+
64+
65+
- name: Build and Push Image
66+
uses: docker/build-push-action@v6
67+
with:
68+
push: true
69+
context: ./
70+
file: ./docs/Dockerfile
71+
tags: us-central1-docker.pkg.dev/${{ env.GAR_PROJECT }}/${{ env.GAR_REGISTRY }}/${{ env.APP_NAME }}:${{ env.TAG }}
72+
73+
- id: output-image
74+
run: echo "image=`echo us-central1-docker.pkg.dev/${{ env.GAR_PROJECT }}/${{ env.GAR_REGISTRY }}/${{ env.APP_NAME }}:${{ env.TAG }}`" >> "$GITHUB_OUTPUT"
75+
76+
deployment_stage:
77+
runs-on: ubuntu-latest
78+
name: 🚀 Deploy-Stage
79+
needs: dockerize
80+
container:
81+
image: ghcr.io/zopsmart/gha-images:deployments-0.1.3
82+
options: --rm
83+
env:
84+
image: ${{needs.dockerize.outputs.image}}
85+
86+
steps:
87+
- name: Checkout Code
88+
uses: actions/checkout@v5
89+
90+
- name: Authorize to GCP service account
91+
uses: google-github-actions/auth@v3
92+
with:
93+
credentials_json: ${{ secrets.GOFR_WEBSITE_GOFR_DEV_STG_DEPLOYMENT_KEY }}
94+
95+
- name: Set GCloud Project and Fetch Cluster Credentials
96+
run: gcloud container clusters get-credentials ${{ env.CLUSTER_NAME }} --region=us-central1 --project=${{ env.CLUSTER_PROJECT }}
97+
98+
- name: Update Deployment Image
99+
run: kubectl set image deployment/${{ env.APP_NAME }} ${{ env.APP_NAME }}=${{ env.image }} --namespace ${{ env.NAMESPACE_STAGE }}

0 commit comments

Comments
 (0)