-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathutils-pr-pipeline.yml
More file actions
125 lines (105 loc) · 4.07 KB
/
utils-pr-pipeline.yml
File metadata and controls
125 lines (105 loc) · 4.07 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
115
116
117
118
119
120
121
122
123
124
125
name: "$(SourceBranchName)+$(BuildID)"
trigger:
branches:
include:
- tags/refs/v*
tags:
include:
- v*
pr:
branches:
include: ['*']
resources:
repositories:
- repository: common
type: github
name: NHSDigital/api-management-utils
ref: refs/heads/master
endpoint: NHSDigital
jobs:
- job: test
displayName: Test ansible
timeoutInMinutes: 30
pool:
name: 'AWS-ECS'
workspace:
clean: all
steps:
- task: UsePythonVersion@0
displayName: 'Use Python 3.9'
inputs:
versionSpec: 3.9
- bash: |
instance_id="$(curl -s http://169.254.169.254/latest/meta-data/instance-id)"
echo instance-id: "${instance_id}"
echo connect to: https://eu-west-2.console.aws.amazon.com/systems-manager/session-manager/${instance_id}
echo sudo su - ubuntu
or
echo ssh ubuntu@${instance_id}
echo working directory: $(System.DefaultWorkingDirectory)
displayName: print aws info
- template: ./components/aws-clean-config.yml
- template: ./components/aws-assume-role.yml
parameters:
role: "auto-ops"
profile: "apm_ptl"
- template: ./components/get-aws-secrets-and-ssm-params.yml
parameters:
secret_ids:
- ptl/access-tokens/github/repo-status-update/GITHUB_ACCESS_TOKEN
config_ids:
- /ptl/azure-devops/GITHUB_USER
- bash: |
echo "Build.SourceBranch: $(Build.SourceBranch)"
echo "Build.SourceBranchName: $(Build.SourceBranchName)"
echo "Build.SourceVersion: $(Build.SourceVersion)"
echo "Build.SourceVersionMessage: $(Build.SourceVersionMessage)"
if [[ ! -z $(NOTIFY_COMMIT_SHA) ]]; then
echo "##[debug]Using already provided NOTIFY_COMMIT_SHA=$(NOTIFY_COMMIT_SHA)"
else
NOTIFY_COMMIT_SHA=""
if [[ "$(Build.SourceBranch)" =~ ^refs/tags/.+$ ]]; then
echo "##[debug]Build appears to be a tag build"
echo "##[debug]Using Build.SourceVersion as NOTIFY_COMMIT_SHA"
NOTIFY_COMMIT_SHA="$(Build.SourceVersion)"
fi
if [[ "$(Build.SourceBranch)" =~ ^refs/pull/.+$ ]]; then
echo "##[debug]Build appears to be a pull request build"
echo "##[debug]Extracting NOTIFY_COMMIT_SHA from Build.SourceVersionMessage"
NOTIFY_COMMIT_SHA=`echo "$(Build.SourceVersionMessage)" | cut -d' ' -f2`
fi
if [[ -z $NOTIFY_COMMIT_SHA ]]; then
echo "##[debug]Build does not appear to be pull or tag build"
echo "##[debug]Using Build.SourceVersion as NOTIFY_COMMIT_SHA"
NOTIFY_COMMIT_SHA="$(Build.SourceVersion)"
fi
echo "##vso[task.setvariable variable=NOTIFY_COMMIT_SHA]$NOTIFY_COMMIT_SHA"
fi
displayName: Set NOTIFY_COMMIT_SHA
condition: always()
- template: ./components/update-github-status.yml
parameters:
state: pending
description: "Testing ansible collection"
- bash: |
ls -R
make install
displayName: Install utils pre-requisites
- bash: |
ANSIBLE_FORCE_COLOR=yes poetry run ansible-test units --python=3.9
workingDirectory: ansible/collections/ansible_collections/nhsd/apigee
displayName: Unit test ansible
- bash: |
ANSIBLE_FORCE_COLOR=yes poetry run ansible-test integration --python=3.9
workingDirectory: ansible/collections/ansible_collections/nhsd/apigee
displayName: Integration test ansible
- template: ./components/update-github-status.yml
parameters:
state: success
on_success: true
description: "Ansible collection tests passed"
- template: ./components/update-github-status.yml
parameters:
state: failure
on_failure: true
description: "Ansible collection tests failed"