-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add yaml pipelines under pagopa subscription
- Loading branch information
1 parent
7eb685f
commit 5923023
Showing
2 changed files
with
315 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
# Azure DevOps pipeline to build, check source codes and run tests. | ||
# | ||
# To make Danger JS run on a pull request you need to add the following pipeline | ||
# variable and set it with a GitHub access token (scope public_repo); otherwise | ||
# set its value to 'skip' without marking it secret: | ||
# - DANGER_GITHUB_API_TOKEN | ||
# | ||
|
||
variables: | ||
NODE_VERSION: '14.16.0' | ||
YARN_CACHE_FOLDER: $(Pipeline.Workspace)/.yarn | ||
|
||
# Automatically triggered on PR | ||
# https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=azure-devops&tabs=schema%2Cparameter-schema#pr-trigger | ||
trigger: none | ||
|
||
pool: | ||
vmImage: 'ubuntu-latest' | ||
|
||
stages: | ||
- stage: Build | ||
dependsOn: [] | ||
jobs: | ||
- job: make_build | ||
steps: | ||
- template: azure-templates/setup-project.yml | ||
- script: | | ||
yarn build | ||
displayName: 'Build' | ||
- stage: Static_analysis | ||
dependsOn: [] | ||
jobs: | ||
- job: lint | ||
steps: | ||
- template: azure-templates/setup-project.yml | ||
- script: | | ||
yarn lint | ||
displayName: 'Lint' | ||
- job: danger | ||
condition: | ||
and( | ||
succeeded(), | ||
and( | ||
eq(variables['Build.Reason'], 'PullRequest'), | ||
ne(variables['DANGER_GITHUB_API_TOKEN'], 'skip') | ||
) | ||
) | ||
steps: | ||
- template: azure-templates/setup-project.yml | ||
- bash: | | ||
yarn danger ci | ||
env: | ||
DANGER_GITHUB_API_TOKEN: '$(DANGER_GITHUB_API_TOKEN)' | ||
displayName: 'Danger CI' | ||
- stage: Unit_Tests | ||
pool: | ||
vmImage: 'ubuntu-latest' | ||
dependsOn: [] | ||
jobs: | ||
- job: unit_tests | ||
steps: | ||
- template: azure-templates/setup-project.yml | ||
|
||
- script: | | ||
yarn generate | ||
displayName: 'Generate definitions' | ||
- script: | | ||
yarn test:coverage | ||
displayName: 'Unit tests' | ||
- bash: | | ||
bash <(curl -s https://codecov.io/bash) | ||
displayName: 'Code coverage' | ||
- stage: Integration_Tests | ||
pool: | ||
vmImage: 'ubuntu-latest' | ||
dependsOn: [] | ||
jobs: | ||
- job: integration_tests | ||
steps: | ||
- template: azure-templates/setup-project.yml | ||
|
||
- script: | | ||
yarn generate | ||
displayName: 'Generate definitions' | ||
- script: | | ||
docker run -d -p 6379:6379 --name redis redis | ||
displayName: 'Start redis' | ||
- script: | | ||
yarn test:integration | ||
displayName: 'Unit tests integration' | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,215 @@ | ||
# Azure DevOps pipeline to release a new version and deploy to production. | ||
|
||
parameters: | ||
- name: 'RELEASE_SEMVER' | ||
displayName: 'When packing a release, define the version bump to apply' | ||
type: string | ||
values: | ||
- major | ||
- minor | ||
- patch | ||
default: minor | ||
- name: ENV | ||
displayName: Target Environment | ||
type: string | ||
default: test | ||
values: | ||
- test | ||
- prod | ||
|
||
variables: | ||
NODE_VERSION: '14.16.0' | ||
YARN_CACHE_FOLDER: $(Pipeline.Workspace)/.yarn | ||
ENV: ${{ parameters.ENV }} | ||
|
||
# Only manual activations are intended | ||
trigger: none | ||
pr: none | ||
|
||
# This pipeline has been implemented to be run on hosted agent pools based both | ||
# on 'windows' and 'ubuntu' virtual machine images and using the scripts defined | ||
# in the package.json file. Since we are deploying on Azure functions on Windows | ||
# runtime, the pipeline is currently configured to use a Windows hosted image for | ||
# the build and deploy. | ||
pool: | ||
vmImage: 'windows-2019' | ||
|
||
resources: | ||
repositories: | ||
- repository: pagopaCommons | ||
type: github | ||
name: pagopa/azure-pipeline-templates | ||
ref: refs/tags/v4 | ||
endpoint: 'pagopa' | ||
|
||
stages: | ||
|
||
# Create a relase | ||
# Activated when ONE OF these are met: | ||
# - is on branch master | ||
# - is a tag in the form v{version}-RELEASE | ||
- stage: Release | ||
#condition: | ||
# and( | ||
# succeeded(), | ||
# or( | ||
# eq(variables['Build.SourceBranch'], 'refs/heads/master'), | ||
# and( | ||
# startsWith(variables['Build.SourceBranch'], 'refs/tags'), | ||
# endsWith(variables['Build.SourceBranch'], '-RELEASE') | ||
# ) | ||
# ) | ||
# ) | ||
pool: | ||
vmImage: 'ubuntu-latest' | ||
jobs: | ||
- job: make_release | ||
steps: | ||
- ${{ if eq(variables['Build.SourceBranch'], 'refs/heads/master') }}: | ||
- template: templates/node-github-release/template.yaml@pagopaCommons | ||
parameters: | ||
semver: '${{ parameters.RELEASE_SEMVER }}' | ||
gitEmail: $(GIT_EMAIL) | ||
gitUsername: $(GIT_USERNAME) | ||
gitHubConnection: $(GITHUB_CONNECTION) | ||
nodeVersion: $(NODE_VERSION) | ||
pkg_cache_version_id: $(CACHE_VERSION_ID) | ||
pkg_cache_folder: $(YARN_CACHE_FOLDER) | ||
|
||
- ${{ if ne(variables['Build.SourceBranch'], 'refs/heads/master') }}: | ||
- script: | | ||
echo "We assume this reference to be a valid release: $(Build.SourceBranch). Therefore, there is no need to bundle a new release." | ||
displayName: 'Skip release bundle' | ||
# Prepare Artifact | ||
- stage: Prepare_artifact | ||
dependsOn: | ||
- Release | ||
jobs: | ||
- job: make_build | ||
steps: | ||
- template: azure-templates/setup-project.yml | ||
parameters: | ||
# On the assumption that this stage is executed only when Relase stage is, | ||
# with this parameter we set the reference the deploy script must pull changes from. | ||
# The branch/tag name is calculated from the source branch | ||
# ex: Build.SourceBranch=refs/heads/master --> master | ||
# ex: Build.SourceBranch=refs/tags/v1.2.3-RELEASE --> v1.2.3-RELEASE | ||
gitReference: ${{ replace(replace(variables['Build.SourceBranch'], 'refs/tags/', ''), 'refs/heads/', '') }} | ||
|
||
- script: | | ||
yarn build | ||
displayName: 'Build' | ||
- task: CopyFiles@2 | ||
inputs: | ||
SourceFolder: '$(System.DefaultWorkingDirectory)' | ||
TargetFolder: '$(System.DefaultWorkingDirectory)/bundle' | ||
Contents: | | ||
**/* | ||
web.config | ||
!.git/**/* | ||
!**/*.js.map | ||
!**/*.ts | ||
!.vscode/**/* | ||
!.devops/**/* | ||
!.prettierrc | ||
!.gitignore | ||
!README.md | ||
!jest.integration.js | ||
!test | ||
!tsconfig.json | ||
!tslint.json | ||
!yarn.lock | ||
!Dangerfile.js | ||
!CODEOWNERS | ||
!Dockerfile | ||
!preview.hbs | ||
!.auto-changelog.json | ||
!api_pagopa.yaml | ||
!__*/**/* | ||
displayName: 'Copy bundle files' | ||
|
||
- publish: $(System.DefaultWorkingDirectory)/bundle | ||
artifact: Bundle | ||
|
||
- stage: Deploy_test | ||
dependsOn: | ||
- Prepare_artifact | ||
jobs: | ||
- job: 'deploy' | ||
steps: | ||
- checkout: none | ||
|
||
- download: current | ||
artifact: Bundle | ||
|
||
- task: AzureWebApp@1 | ||
inputs: | ||
azureSubscription: '$(PRODUCTION_AZURE_SUBSCRIPTION)' | ||
resourceGroupName: '$(PRODUCTION_RESOURCE_GROUP_NAME)' | ||
appType: 'webApp' | ||
appName: '$(PRODUCTION_PROXYTEST_APP_NAME)' | ||
package: '$(Pipeline.Workspace)/Bundle' | ||
deploymentMethod: 'auto' | ||
displayName: Deploy to production slot | ||
|
||
- stage: Api_test | ||
dependsOn: | ||
- Deploy_test | ||
jobs: | ||
- job: 'TestAPI' | ||
steps: | ||
- checkout: none | ||
|
||
- download: current | ||
artifact: Bundle | ||
|
||
- job: waitStartup | ||
steps: | ||
- task: Delay@1 | ||
inputs: | ||
delayForMinutes: '5' | ||
|
||
- job: integrationTests | ||
dependsOn: waitStartup | ||
steps: | ||
- script: | | ||
yarn global add newman | ||
displayName: 'newman installation' | ||
- task: Bash@3 | ||
inputs: | ||
targetType: filePath | ||
filePath: k6example/ws.sh | ||
arguments: postman | ||
workingDirectory: k6example | ||
failOnStdErr: true | ||
displayName: Run API tests | ||
|
||
- stage: Deploy_production | ||
dependsOn: | ||
- Prepare_artifact | ||
condition: | ||
and( | ||
succeeded(), | ||
eq(variables['ENV'], 'prod') | ||
) | ||
jobs: | ||
- job: 'deploy' | ||
steps: | ||
- checkout: none | ||
|
||
- download: current | ||
artifact: Bundle | ||
|
||
- task: AzureWebApp@1 | ||
inputs: | ||
azureSubscription: '$(PRODUCTION_AZURE_SUBSCRIPTION)' | ||
resourceGroupName: '$(PRODUCTION_RESOURCE_GROUP_NAME)' | ||
appType: 'webApp' | ||
appName: '$(PRODUCTION_PROXYPROD_APP_NAME)' | ||
package: '$(Pipeline.Workspace)/Bundle' | ||
deploymentMethod: 'auto' | ||
displayName: Deploy to production slot |