110 lines (96 loc) · 3.46 KB
/
azure-terraform-integration-tests.yml
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
name: Azure Discovery Plugin Tests
on:
workflow_dispatch:
pull_request_target:
types:
- labeled
branches:
- "master"
- "*.z"
paths:
- "hazelcast/src/main/java/com/hazelcast/azure/**"
- ".github/terraform/azure/**"
jobs:
build:
name: Azure Tests
defaults:
run:
shell: bash
runs-on: ubuntu-latest
if: >-
github.repository_owner == 'hazelcast' &&
( github.event_name == 'workflow_dispatch' ||
(github.event_name == 'pull_request_target' &&
github.event.action == 'labeled' &&
github.event.label.name == 'run-discovery-tests'
)
)
env:
AWS_REGION: us-east-1
steps:
- name: Decide which ref to checkout
id: decide-ref
run: |
if [[ "${{github.event_name}}" == "pull_request_target" ]]; then
echo "ref=refs/pull/${{ github.event.pull_request.number }}/merge" >> $GITHUB_OUTPUT
else
echo "ref=${{github.ref}}" >> $GITHUB_OUTPUT
fi
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{steps.decide-ref.outputs.ref}}
- name: Read Java Config
uses: pietrobolcato/action-read-yaml@9f13718d61111b69f30ab4ac683e67a56d254e1d
id: java-config
with:
config: ${{ github.workspace }}/.github/java-config.yml
- name: Setup JDK
uses: actions/setup-java@v4
with:
java-version: ${{ steps.java-config.outputs['java-version'] }}
distribution: ${{ steps.java-config.outputs['distribution'] }}
architecture: x64
cache: "maven"
- name: Build hazelcast jar
run: |
./mvnw -T 4 -B -V -e clean package --activate-profiles quick
echo "Hazelcast jar is: " hazelcast/target/hazelcast-*-SNAPSHOT.jar
cp hazelcast/target/hazelcast-*-SNAPSHOT.jar ~/hazelcast.jar
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4.0.2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
- name: Get Secrets
uses: aws-actions/aws-secretsmanager-get-secrets@v2
with:
secret-ids: |
AZURE_CREDENTIALS,CN/AZURE_CREDENTIALS
- name: Azure login
uses: azure/login@v2
with:
creds: ${{ env.AZURE_CREDENTIALS }}
- name: Set Azure ServicePrincipal authentication env vars
run: |
export ARM_CLIENT_ID=$(echo $AZURE_CREDENTIALS | jq -r .clientId)
export ARM_CLIENT_SECRET=$(echo $AZURE_CREDENTIALS | jq -r .clientSecret)
export ARM_SUBSCRIPTION_ID=$(echo $AZURE_CREDENTIALS | jq -r .subscriptionId)
export ARM_TENANT_ID=$(echo $AZURE_CREDENTIALS | jq -r .tenantId)
- name: Set-up Terraform
uses: hashicorp/setup-terraform@v3.1.1
- name: Terraform Init
working-directory: .github/terraform/azure
run: terraform init
- name: Terraform Apply
working-directory: .github/terraform/azure
run: |
terraform apply \
-var="hazelcast_mancenter_version=latest-snapshot" \
-var="hazelcast_path=~/hazelcast.jar" \
-auto-approve
- name: Terraform Destroy
if: ${{ always() }}
working-directory: .github/terraform/azure
run: terraform destroy -auto-approve