-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathazure-pipeline.yml
100 lines (97 loc) · 3.51 KB
/
azure-pipeline.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
# Python to Linux Web App on Azure
# Build your Python project and deploy it to Azure as a Linux Web App.
# Change python version to one thats appropriate for your application.
# https://docs.microsoft.com/azure/devops/pipelines/languages/python
trigger:
- main
variables:
# Azure Resource Manager connection created during pipeline creation
azureServiceConnectionId: "0c9df823-c46e-48c7-aead-8da6f31a0926"
# Agent VM image name
vmImageName: "ubuntu-latest"
# Environment name
environmentName: "Test"
# Project root folder. Point to the folder containing manage.py file.
projectRoot: $(System.DefaultWorkingDirectory)
# Python version: 3.11
pythonVersion: "3.11"
stages:
- stage: LintAndVulnerabilityScanning
displayName: LintAndVulnerabilityScanning
dependsOn: []
jobs:
- job: LintAndVulnerabilityScanning
pool:
vmImage: $(vmImageName)
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: "$(pythonVersion)"
displayName: "Use Python $(pythonVersion)"
- script: |
curl -sSL https://install.python-poetry.org | python3 -
echo "export PATH"="/home/hukadmin/.local/bin:$PATH">>~/.bashrc
source ~/.bashrc
make activate
make install
workingDirectory: $(projectRoot)
displayName: "Install Poetry and Dependencies"
- script: |
make format-lint
workingDirectory: $(projectRoot)
displayName: "Format Lint"
- script: |
make sast
workingDirectory: $(projectRoot)
displayName: "Static Analysis"
- script: |
make dependency-vulnerability-scan
workingDirectory: $(projectRoot)
displayName: "Dependency Vulnerability Scan"
- stage: Tests
displayName: Tests
dependsOn: []
jobs:
- job: Testing
pool:
vmImage: $(vmImageName)
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: "$(pythonVersion)"
displayName: "Use Python $(pythonVersion)"
- script: |
curl -sSL https://install.python-poetry.org | python3 -
echo "export PATH"="/home/hukadmin/.local/bin:$PATH">>~/.bashrc
source ~/.bashrc
make activate
make install
workingDirectory: $(projectRoot)
displayName: "Install Poetry and Dependencies"
- script: |
make unit-test
workingDirectory: $(projectRoot)
displayName: "Unit Testing"
- script: |
make mutation-testing
workingDirectory: $(projectRoot)
displayName: "Mutation Testing"
- script: |
make bdd-test
workingDirectory: $(projectRoot)
displayName: "BDD Test"
- stage: APPDeploymentToAzureVM
displayName: "APP Deployment To Azure VM"
dependsOn: ["LintAndVulnerabilityScanning", "Tests"]
jobs:
- job: APPDeploymentToAzureVM
displayName: "APP Deployment To Azure VM"
dependsOn: []
steps:
- script: |
sudo apt update && sudo apt install sshpass -y && mkdir ~/.ssh/ && touch ~/.ssh/known_hosts && ssh-keyscan $PUBLIC_IP >> ~/.ssh/known_hosts
sudo sshpass -p Password1234! ssh hukadmin@$PUBLIC_IP
pwd
ls
cd /home/hukadmin/
displayName: 'APPDeploymentToAzureVM'