Skip to content

Commit 92b5454

Browse files
committed
APM-Python-Upgrade
1 parent 4dd1844 commit 92b5454

File tree

7 files changed

+962
-841
lines changed

7 files changed

+962
-841
lines changed

.github/workflows/publish.yml

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -3,49 +3,49 @@ name: Publish / Calculate Version
33
on: push
44

55
jobs:
6-
build:
7-
name: calculate version
8-
runs-on: ubuntu-22.04
9-
steps:
10-
- name: Checkout
11-
uses: actions/checkout@v2
12-
with:
13-
fetch-depth: 0 # This causes all history to be fetched, which is required for calculate-version to function
14-
15-
- name: Install Python 3.8
16-
uses: actions/setup-python@v5
17-
with:
18-
python-version: 3.8
19-
20-
- name: Install poetry
21-
run: pip install poetry
22-
23-
- name: Cache poetry packages
24-
uses: actions/cache@v4
25-
id: cache
26-
with:
27-
path: ~/.venv
28-
key: ${{ runner.os }}-utils-venv-${{ hashFiles('**/poetry.lock') }}
29-
30-
- name: Install
31-
run: poetry install
32-
if: steps.cache.outputs.cache-hit != 'true'
33-
34-
- name: Set SPEC_VERSION env var
35-
run: |
36-
version="$(poetry run python scripts/calculate_version.py)"
37-
echo "${version}"
38-
echo ::set-env name=SPEC_VERSION::${version}
39-
env:
40-
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
41-
42-
- name: Create release (master only)
43-
id: create-release
44-
if: github.ref == 'refs/heads/master'
45-
uses: actions/create-release@v1
46-
continue-on-error: true
47-
env:
48-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49-
with:
50-
tag_name: ${{ env.SPEC_VERSION }}
51-
release_name: ${{ env.SPEC_VERSION }}
6+
build:
7+
name: calculate version
8+
runs-on: ubuntu-22.04
9+
steps:
10+
- name: Checkout
11+
uses: actions/checkout@v2
12+
with:
13+
fetch-depth: 0 # This causes all history to be fetched, which is required for calculate-version to function
14+
15+
- name: Install Python 3.9
16+
uses: actions/setup-python@v5
17+
with:
18+
python-version: 3.9
19+
20+
- name: Install poetry
21+
run: pip install poetry
22+
23+
- name: Cache poetry packages
24+
uses: actions/cache@v4
25+
id: cache
26+
with:
27+
path: ~/.venv
28+
key: ${{ runner.os }}-utils-venv-${{ hashFiles('**/poetry.lock') }}
29+
30+
- name: Install
31+
run: poetry install
32+
if: steps.cache.outputs.cache-hit != 'true'
33+
34+
- name: Set SPEC_VERSION env var
35+
run: |
36+
version="$(poetry run python scripts/calculate_version.py)"
37+
echo "${version}"
38+
echo ::set-env name=SPEC_VERSION::${version}
39+
env:
40+
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
41+
42+
- name: Create release (master only)
43+
id: create-release
44+
if: github.ref == 'refs/heads/master'
45+
uses: actions/create-release@v1
46+
continue-on-error: true
47+
env:
48+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49+
with:
50+
tag_name: ${{ env.SPEC_VERSION }}
51+
release_name: ${{ env.SPEC_VERSION }}

azure/build-prereqs.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
parameters:
2-
- name: 'utils_dir'
2+
- name: "utils_dir"
33
type: string
4-
default: 'utils'
4+
default: "utils"
55

66
steps:
77
- task: UsePythonVersion@0
88
inputs:
9-
versionSpec: '3.8'
9+
versionSpec: "3.9"
1010

1111
- bash: |
1212
tfenv use 0.14.6

azure/common/apigee-build.yml

Lines changed: 72 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ parameters:
2929
default: []
3030
- name: python_version
3131
type: string
32-
default: "3.8"
32+
default: "3.9"
3333
- name: agent_pool
3434
type: string
3535
default: "AWS-ECS"
@@ -46,7 +46,6 @@ jobs:
4646
${{ each var in parameters.variables }}:
4747
${{ var.key }}: ${{ var.value }}
4848
steps:
49-
5049
- bash: |
5150
if [ ! -z "$(ls -A \"$(Pipeline.Workspace)/s/${{ parameters.service_name }}\" 2>/dev/null)" ]; then
5251
echo "workspace directory is not empty!"
@@ -67,63 +66,63 @@ jobs:
6766
- template: ../components/aws-clean-config.yml
6867

6968
- ${{ if parameters.notify }}:
70-
- template: ../components/aws-assume-role.yml
71-
parameters:
72-
role: "auto-ops"
73-
profile: "apm_ptl"
74-
75-
- template: ../components/get-aws-secrets-and-ssm-params.yml
76-
parameters:
77-
secret_file_ids:
78-
- ${{ each secret_file_id in parameters.secret_file_ids }}:
79-
- ${{ secret_file_id }}
80-
secret_ids:
81-
- ptl/access-tokens/github/repo-status-update/GITHUB_ACCESS_TOKEN
82-
- ${{ each secret_id in parameters.secret_ids }}:
83-
- ${{ secret_id }}
84-
config_ids:
85-
- /ptl/azure-devops/GITHUB_USER
86-
- ${{ each config_id in parameters.config_ids }}:
87-
- ${{ config_id }}
88-
89-
- bash: |
90-
echo "Build.SourceBranch: $(Build.SourceBranch)"
91-
echo "Build.SourceBranchName: $(Build.SourceBranchName)"
92-
echo "Build.SourceVersion: $(Build.SourceVersion)"
93-
echo "Build.SourceVersionMessage: $(Build.SourceVersionMessage)"
94-
95-
if [[ ! -z $(NOTIFY_COMMIT_SHA) ]]; then
96-
echo "##[debug]Using already provided NOTIFY_COMMIT_SHA=$(NOTIFY_COMMIT_SHA)"
97-
else
98-
NOTIFY_COMMIT_SHA=""
99-
100-
if [[ "$(Build.SourceBranch)" =~ ^refs/tags/.+$ ]]; then
101-
echo "##[debug]Build appears to be a tag build"
102-
echo "##[debug]Using Build.SourceVersion as NOTIFY_COMMIT_SHA"
103-
NOTIFY_COMMIT_SHA="$(Build.SourceVersion)"
104-
fi
105-
106-
if [[ "$(Build.SourceBranch)" =~ ^refs/pull/.+$ ]]; then
107-
echo "##[debug]Build appears to be a pull request build"
108-
echo "##[debug]Extracting NOTIFY_COMMIT_SHA from Build.SourceVersionMessage"
109-
NOTIFY_COMMIT_SHA=`echo "$(Build.SourceVersionMessage)" | cut -d' ' -f2`
110-
fi
111-
112-
if [[ -z $NOTIFY_COMMIT_SHA ]]; then
113-
echo "##[debug]Build does not appear to be pull or tag build"
114-
echo "##[debug]Using Build.SourceVersion as NOTIFY_COMMIT_SHA"
115-
NOTIFY_COMMIT_SHA="$(Build.SourceVersion)"
116-
fi
117-
118-
echo "##vso[task.setvariable variable=NOTIFY_COMMIT_SHA]$NOTIFY_COMMIT_SHA"
119-
fi
120-
displayName: Set NOTIFY_COMMIT_SHA
121-
condition: always()
122-
123-
- template: '../components/update-github-status.yml'
124-
parameters:
125-
state: pending
126-
description: "Build started"
69+
- template: ../components/aws-assume-role.yml
70+
parameters:
71+
role: "auto-ops"
72+
profile: "apm_ptl"
73+
74+
- template: ../components/get-aws-secrets-and-ssm-params.yml
75+
parameters:
76+
secret_file_ids:
77+
- ${{ each secret_file_id in parameters.secret_file_ids }}:
78+
- ${{ secret_file_id }}
79+
secret_ids:
80+
- ptl/access-tokens/github/repo-status-update/GITHUB_ACCESS_TOKEN
81+
- ${{ each secret_id in parameters.secret_ids }}:
82+
- ${{ secret_id }}
83+
config_ids:
84+
- /ptl/azure-devops/GITHUB_USER
85+
- ${{ each config_id in parameters.config_ids }}:
86+
- ${{ config_id }}
87+
88+
- bash: |
89+
echo "Build.SourceBranch: $(Build.SourceBranch)"
90+
echo "Build.SourceBranchName: $(Build.SourceBranchName)"
91+
echo "Build.SourceVersion: $(Build.SourceVersion)"
92+
echo "Build.SourceVersionMessage: $(Build.SourceVersionMessage)"
93+
94+
if [[ ! -z $(NOTIFY_COMMIT_SHA) ]]; then
95+
echo "##[debug]Using already provided NOTIFY_COMMIT_SHA=$(NOTIFY_COMMIT_SHA)"
96+
else
97+
NOTIFY_COMMIT_SHA=""
98+
99+
if [[ "$(Build.SourceBranch)" =~ ^refs/tags/.+$ ]]; then
100+
echo "##[debug]Build appears to be a tag build"
101+
echo "##[debug]Using Build.SourceVersion as NOTIFY_COMMIT_SHA"
102+
NOTIFY_COMMIT_SHA="$(Build.SourceVersion)"
103+
fi
104+
105+
if [[ "$(Build.SourceBranch)" =~ ^refs/pull/.+$ ]]; then
106+
echo "##[debug]Build appears to be a pull request build"
107+
echo "##[debug]Extracting NOTIFY_COMMIT_SHA from Build.SourceVersionMessage"
108+
NOTIFY_COMMIT_SHA=`echo "$(Build.SourceVersionMessage)" | cut -d' ' -f2`
109+
fi
110+
111+
if [[ -z $NOTIFY_COMMIT_SHA ]]; then
112+
echo "##[debug]Build does not appear to be pull or tag build"
113+
echo "##[debug]Using Build.SourceVersion as NOTIFY_COMMIT_SHA"
114+
NOTIFY_COMMIT_SHA="$(Build.SourceVersion)"
115+
fi
116+
117+
echo "##vso[task.setvariable variable=NOTIFY_COMMIT_SHA]$NOTIFY_COMMIT_SHA"
118+
fi
119+
displayName: Set NOTIFY_COMMIT_SHA
120+
condition: always()
121+
122+
- template: "../components/update-github-status.yml"
123+
parameters:
124+
state: pending
125+
description: "Build started"
127126

128127
- bash: |
129128
if [[ ! -z $(UTILS_PR_NUMBER) ]]; then
@@ -193,12 +192,12 @@ jobs:
193192
key: poetry | $(System.DefaultWorkingDirectory) | ${{ parameters.service_name }}/utils/poetry.lock
194193
location: "${{ parameters.service_name }}/utils/.venv"
195194
debug: true
196-
alias: 'Utils'
195+
alias: "Utils"
197196
displayName: cache utils dependencies
198197

199198
- bash: |
200-
make install
201-
sleep 5
199+
make install
200+
sleep 5
202201
workingDirectory: "${{ parameters.service_name }}/utils"
203202
condition: ne(variables['CacheRestored-Utils'], 'true')
204203
displayName: "Install utils "
@@ -277,14 +276,14 @@ jobs:
277276
artifact: "$(Build.BuildNumber)"
278277

279278
- ${{ if parameters.notify }}:
280-
- template: '../components/update-github-status.yml'
281-
parameters:
282-
state: success
283-
on_success: true
284-
description: "Build succeeded"
285-
286-
- template: '../components/update-github-status.yml'
287-
parameters:
288-
state: failure
289-
on_failure: true
290-
description: "Build failed"
279+
- template: "../components/update-github-status.yml"
280+
parameters:
281+
state: success
282+
on_success: true
283+
description: "Build succeeded"
284+
285+
- template: "../components/update-github-status.yml"
286+
parameters:
287+
state: failure
288+
on_failure: true
289+
description: "Build failed"

0 commit comments

Comments
 (0)