-
Notifications
You must be signed in to change notification settings - Fork 0
114 lines (96 loc) · 3.43 KB
/
ci.yml
File metadata and controls
114 lines (96 loc) · 3.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
name: CI Pipeline
on:
push:
branches:
- '*'
tags:
- 'v*.*'
pull_request:
branches:
- '*'
workflow_dispatch:
jobs:
check-generated-and-lint-code:
name: Check Generated files and lint Code
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Install Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: Run Make Generate
run: make generate
- name: Check for Uncommitted Changes
run: |
if [ -n "$(git status --porcelain)" ]; then
echo "::error::Files were modified after running 'make generate'. Please run 'make generate' locally and commit the changes."
git status
git diff
exit 1
else
echo "Generated code is up to date!"
fi
- name: Run Make Prepare
run: make prepare
test-and-resources:
name: Test & Resource Management
runs-on: ubuntu-latest
env:
ENVIRONMENT: pubsub.eu01.qa.onstackit.cloud
TOKEN_CUSTOM_URI: https://service-account.api.qa.stackit.cloud/token
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: Load Key from GitHub Secrets
run: |
echo '${{ secrets.STACKIT_SERVICE_ACCOUNT_KEY }}' > $RUNNER_TEMP/service_account_key.json
- name: Set up Stackit CLI
run: |
echo "Stackit CLI Installation"
sudo snap install stackit --classic
- name: Import QA Profile and Login
if: always()
run: |
echo '${{ secrets.STACKIT_QA_ENV_JSON }}' > $RUNNER_TEMP/qa-env.json
if stackit config profile list | grep -q "pubsub-qa"; then
echo "Profile 'pubsub-qa' found, deleting it."
stackit config profile unset -y || true
stackit config profile delete pubsub-qa -y --verbosity debug
echo "deleted"
else
echo "Profile 'pubsub-qa' not found, skipping deletion."
fi
echo "pubsub-qa should been removed. Creating..."
stackit config profile import -c "@$RUNNER_TEMP/qa-env.json" --name pubsub-qa
stackit config profile set pubsub-qa
stackit auth activate-service-account --service-account-key-path "$RUNNER_TEMP/service_account_key.json"
- name: Create PubSub Topic and Subscription
run: ./scripts/create-pubsub-resources.sh
env:
REPO_ROOT: ${{ github.workspace }}
SA_KEY_PATH: ${{ runner.temp }}/service_account_key.json
- name: Run Unit Tests
run: make test ENABLE_TEST_COVERAGE=true
env:
TOPIC_ID: ${{ env.TOPIC_ID }}
SUBSCRIPTION_ID: ${{ env.SUBSCRIPTION_ID }}
ENVIRONMENT: ${{ env.ENVIRONMENT }}
TOKEN_CUSTOM_URI: ${{ env.TOKEN_CUSTOM_URI }}
SERVICE_ACCOUNT_TOKEN: ${{ secrets.STACKIT_SERVICE_ACCOUNT_KEY }}
TOKEN: ${{ secrets.TOKEN }}
- name: Cleanup - Delete STACKIT Resources
if: always()
run: |
cp $RUNNER_TEMP/service_account_key.json key.json
./scripts/delete-pubsub-resources.sh
- name: Delete QA Profile
if: always()
run: stackit config profile delete pubsub-qa -y