Skip to content

Commit 2a3319d

Browse files
author
Sean Sundberg
authored
Updates verify-pr logic (#303)
* Uses custom actions to verify iZero and updates parameters to actions * Adds scheduled workflow to verify master * Adds badge to README and verify on push also * Updates failing slack message Signed-off-by: Sean Sundberg <[email protected]>
1 parent 8544f8f commit 2a3319d

File tree

4 files changed

+96
-62
lines changed

4 files changed

+96
-62
lines changed

.github/scripts/validate-deploy.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env bash
2+
3+
SCRIPT_DIR=$(cd $(dirname $0); pwd -P)
4+
5+
export KUBECONFIG="${PWD}/.kube/config"
6+
7+
set -e
8+
9+
kubectl get pods -A
10+
11+
kubectl get cm cloud-config -n default
12+
13+
exit 0
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Verify
2+
3+
# Controls when the action will run. Triggers the workflow on push or pull request
4+
# events but only for the main branch
5+
on:
6+
push:
7+
branches:
8+
- master
9+
schedule:
10+
- cron: "0 7 * * *"
11+
12+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
13+
jobs:
14+
verify:
15+
runs-on: ubuntu-latest
16+
container: quay.io/ibmgaragecloud/cli-tools:v0.10.0-lite
17+
18+
strategy:
19+
matrix:
20+
platform: [ocp4_latest]
21+
fail-fast: false
22+
23+
env:
24+
HOME: /home/devops
25+
26+
# Steps represent a sequence of tasks that will be executed as part of the job
27+
steps:
28+
- name: Checkout
29+
uses: actions/checkout@v1
30+
31+
- name: Verify deploy on ${{ matrix.platform }}
32+
uses: ibm-garage-cloud/action-module-verify-deploy@main
33+
with:
34+
clusterId: ${{ matrix.platform }}
35+
validateDeployScript: .github/scripts/validate-deploy.sh
36+
testStagesDir: ./terraform/stages
37+
env:
38+
TF_VAR_ibmcloud_api_key: ${{ secrets.IBMCLOUD_API_KEY }}
39+
IBMCLOUD_API_KEY: ${{ secrets.IBMCLOUD_API_KEY }}
40+
41+
- name: Verify destroy on ${{ matrix.platform }}
42+
uses: ibm-garage-cloud/action-module-verify-destroy@main
43+
if: ${{ always() }}
44+
with:
45+
clusterId: ${{ matrix.platform }}
46+
testStagesDir: ./terraform/stages
47+
env:
48+
TF_VAR_ibmcloud_api_key: ${{ secrets.IBMCLOUD_API_KEY }}
49+
IBMCLOUD_API_KEY: ${{ secrets.IBMCLOUD_API_KEY }}
50+
51+
- name: Slack Notification
52+
if: ${{ failure() }}
53+
uses: rtCamp/[email protected]
54+
env:
55+
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
56+
SLACK_USERNAME: "cntkBot"
57+
SLACK_ICON_EMOJI: ":cloudwb:"
58+
SLACK_TITLE: "iZero verify failed"
59+
SLACK_MESSAGE: "Iteration Zero deploy verification failed"
60+
MSG_MINIMAL: true

.github/workflows/verify-pr.yaml

Lines changed: 21 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,52 @@
11
name: Verify PR
22

33
# Controls when the action will run. Triggers the workflow on push or pull request
4-
# events but only for the master branch
4+
# events but only for the main branch
55
on:
66
pull_request:
77
branches: [ master ]
88

99
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
1010
jobs:
1111
verify:
12-
# The type of runner that the job will run on
1312
if: ${{ !contains( github.event.pull_request.labels.*.name, 'skip ci' ) }}
1413
runs-on: ubuntu-latest
1514
container: quay.io/ibmgaragecloud/cli-tools:v0.10.0-lite
1615

1716
strategy:
1817
matrix:
19-
platform: [ocp44_vpc]
18+
platform: [ocp4_latest]
2019
# max-parallel: 1
2120
fail-fast: false
2221

2322
env:
2423
HOME: /home/devops
25-
NAMESPACE: ${{ secrets.NAMESPACE }}
26-
TF_VAR_tools_namespace: ${{ secrets.NAMESPACE }}
27-
TF_VAR_ibmcloud_api_key: ${{ secrets.IBMCLOUD_API_KEY }}
28-
IBMCLOUD_API_KEY: ${{ secrets.IBMCLOUD_API_KEY }}
29-
TF_VAR_resource_group_name: ${{ secrets.TEST_RESOURCE_GROUP }}
30-
TF_VAR_region: ${{ secrets.TEST_REGION }}
31-
TF_VAR_cluster_name: ${{ secrets[format('TEST_CLUSTER_{0}', matrix.platform)] }}
32-
TF_VAR_cluster_type: ${{ matrix.platform }}
33-
TF_VAR_vpc_cluster: ${{ endswith(matrix.platform, 'vpc') }}
34-
TF_VAR_logdna_exists: "true"
35-
TF_VAR_sysdig_exists: "true"
36-
TF_VAR_cluster_exists: "true"
3724

3825
# Steps represent a sequence of tasks that will be executed as part of the job
3926
steps:
40-
- name: Validate config
41-
run: |
42-
echo "Github sha: ${{ github.sha }}"
43-
echo "Github ref: ${{ github.ref }}"
44-
if [ -z "${NAMESPACE}" ]; then
45-
echo "The NAMESPACE secret has not been set within the Git repo"
46-
exit 1
47-
fi
48-
4927
- name: Checkout
5028
uses: actions/checkout@v1
5129

52-
# Setups up the task
53-
- name: Setup ${{ matrix.platform }}
54-
run: |
55-
ls -lA
56-
mkdir -p /tmp/workspace
57-
cp -R ./terraform/scripts-workspace/* /tmp/workspace
58-
cp -R ./terraform/stages/* /tmp/workspace
59-
cp -R ./test/stages/* /tmp/workspace
60-
61-
# Deploy
62-
- name: Deploy ${{ matrix.platform }}
63-
run: |
64-
cd /tmp/workspace
65-
./apply.sh
66-
67-
# Test deploy
68-
# - name: Validate deploy ${{ matrix.platform }}
69-
# run: |
70-
# cd /tmp/workspace
71-
# ./validate-deploy.sh ${{ matrix.platform }} ${{ env.NAMESPACE }}
72-
73-
# Destroy
74-
# - name: Destroy ${{ matrix.platform }}
75-
# run: |
76-
# cd /tmp/workspace
77-
# ./destroy.sh
30+
- name: Verify deploy on ${{ matrix.platform }}
31+
uses: ibm-garage-cloud/action-module-verify-deploy@main
32+
with:
33+
clusterId: ${{ matrix.platform }}
34+
validateDeployScript: .github/scripts/validate-deploy.sh
35+
testStagesDir: ./terraform/stages
36+
env:
37+
TF_VAR_ibmcloud_api_key: ${{ secrets.IBMCLOUD_API_KEY }}
38+
IBMCLOUD_API_KEY: ${{ secrets.IBMCLOUD_API_KEY }}
39+
40+
- name: Verify destroy on ${{ matrix.platform }}
41+
uses: ibm-garage-cloud/action-module-verify-destroy@main
42+
if: ${{ always() }}
43+
with:
44+
clusterId: ${{ matrix.platform }}
45+
testStagesDir: ./terraform/stages
46+
env:
47+
TF_VAR_ibmcloud_api_key: ${{ secrets.IBMCLOUD_API_KEY }}
48+
IBMCLOUD_API_KEY: ${{ secrets.IBMCLOUD_API_KEY }}
7849

79-
# Test destroy
80-
# - name: Validate destroy ${{ matrix.platform }}
81-
# run: |
82-
# cd /tmp/workspace
83-
# ./capture-cluster-state.sh ${{ matrix.platform }} $PWD/cluster-state/before $PWD/cluster-state/after
84-
# if diff -q $PWD/cluster-state/before $PWD/cluster-state/after 1> /dev/null; then
85-
# echo "Destroy completed successfully"
86-
# else
87-
# echo "Resources don't match"
88-
# diff $PWD/cluster-state/before $PWD/cluster-state/after
89-
# exit 1
90-
# fi
9150
label:
9251
# The type of runner that the job will run on
9352
needs: verify

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
![Latest release](https://img.shields.io/github/v/release/ibm-garage-cloud/ibm-garage-iteration-zero?sort=semver)
44

5+
![Verify workflow](https://github.com/ibm-garage-cloud/ibm-garage-iteration-zero/workflows/verify-master.yml/badge.svg)
6+
57
## Iteration Zero for IBM Cloud
68

79
This repository contains infrastructure as code (IasC) scripting to create an IBM Garage Cloud Native Toolkit

0 commit comments

Comments
 (0)