This repository has been archived by the owner on Jan 15, 2025. It is now read-only.
generated from pagopa/io-functions-template
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit aff7557
Showing
51 changed files
with
10,016 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,5 @@ | ||
{ | ||
"issuePattern": "\\[#(\\d+)\\]", | ||
"issueUrl": "https://www.pivotaltracker.com/story/show/{id}", | ||
"breakingPattern": "BREAKING CHANGE:" | ||
} |
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,30 @@ | ||
# Azure DevOps pipeline template used to setup the Node project: | ||
# 1. checkout code | ||
# 2. setup correct node version | ||
# 3. install node dependencies | ||
|
||
parameters: | ||
# the branch, tag or commit to deploy | ||
- name: 'gitReference' | ||
type: string | ||
default: '$(Build.SourceVersion)' | ||
|
||
steps: | ||
- checkout: self | ||
displayName: 'Checkout' | ||
|
||
# This is needed because the pipeline may point to a different commit than expected | ||
# The common case is when the previous stage pushed another commit | ||
- ${{ if ne(parameters.gitReference, variables['Build.SourceVersion']) }}: | ||
- script: | | ||
git fetch && git checkout ${{ parameters.gitReference }} | ||
displayName: 'Checkout reference' | ||
- task: UseNode@1 | ||
inputs: | ||
version: $(NODE_VERSION) | ||
displayName: 'Set up Node.js' | ||
|
||
- script: | | ||
yarn install --frozen-lockfile --no-progress --non-interactive --network-concurrency 1 | ||
displayName: 'Install node modules' |
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,87 @@ | ||
# 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: '12.19.1' | ||
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 | ||
|
||
# Execute agents (jobs) on latest Ubuntu version. | ||
# To change OS for a specific, ovverride "pool" attribute inside the job definition | ||
pool: | ||
vmImage: 'ubuntu-latest' | ||
|
||
stages: | ||
- stage: Build | ||
dependsOn: [] | ||
jobs: | ||
- job: make_build | ||
pool: | ||
# As we deploy on Wondows machines, we use Windows to build | ||
vmImage: 'windows-2019' | ||
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: validate_api_specification | ||
steps: | ||
- script: | | ||
npx oval validate -p openapi/index.yaml | ||
displayName: 'Validate API specification' | ||
- job: danger | ||
condition: | ||
and( | ||
succeeded(), | ||
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' | ||
# B) Run unit tests if there is a push or pull request on any branch. | ||
- stage: Test | ||
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 exec' | ||
- bash: | | ||
bash <(curl -s https://codecov.io/bash) | ||
displayName: 'Code coverage' |
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,168 @@ | ||
# Azure DevOps pipeline to release a new version and deploy to production. | ||
|
||
variables: | ||
NODE_VERSION: '12.19.1' | ||
YARN_CACHE_FOLDER: $(Pipeline.Workspace)/.yarn | ||
|
||
parameters: | ||
- name: 'RELEASE_SEMVER' | ||
displayName: 'When packing a release, define the version bump to apply' | ||
type: string | ||
values: | ||
- major | ||
- minor | ||
- patch | ||
default: minor | ||
|
||
# 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: Deploy_staging | ||
dependsOn: | ||
- Release | ||
jobs: | ||
- job: 'prepare_artifact_and_deploy' | ||
steps: | ||
# Build application | ||
- 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 predeploy | ||
displayName: 'Build' | ||
# Install functions extensions | ||
- task: DotNetCoreCLI@2 | ||
inputs: | ||
command: "build" | ||
arguments: "-o bin" | ||
# Copy application to | ||
- task: CopyFiles@2 | ||
inputs: | ||
SourceFolder: '$(System.DefaultWorkingDirectory)' | ||
TargetFolder: '$(Build.ArtifactStagingDirectory)' | ||
Contents: | | ||
**/* | ||
!.git/**/* | ||
!**/*.js.map | ||
!**/*.ts | ||
!.vscode/**/* | ||
!azure-templates/**/* | ||
!azure-pipelines.yml | ||
!.prettierrc | ||
!.gitignore | ||
!README.md | ||
!jest.config.js | ||
!local.settings.json | ||
!test | ||
!tsconfig.json | ||
displayName: 'Copy deploy files' | ||
|
||
- task: AzureFunctionApp@1 | ||
inputs: | ||
azureSubscription: '$(PRODUCTION_AZURE_SUBSCRIPTION)' | ||
resourceGroupName: '$(PRODUCTION_RESOURCE_GROUP_NAME)' | ||
appType: 'functionApp' | ||
appName: '$(PRODUCTION_APP_NAME)' | ||
package: '$(Build.ArtifactStagingDirectory)/' | ||
deploymentMethod: 'auto' | ||
deployToSlotOrASE: true | ||
slotName: 'staging' | ||
displayName: Deploy to staging slot | ||
|
||
# Check that the staging instance is healthy | ||
- stage: Healthcheck | ||
dependsOn: | ||
- Deploy_staging | ||
jobs: | ||
- job: 'do_healthcheck' | ||
steps: | ||
- template: templates/rest-healthcheck/template.yaml@pagopaCommons | ||
parameters: | ||
azureSubscription: '$(PRODUCTION_AZURE_SUBSCRIPTION)' | ||
appName: '$(PRODUCTION_APP_NAME)' | ||
endpoint: 'https://$(PRODUCTION_APP_NAME)-staging.azurewebsites.net/template/info' | ||
endpointType: 'private' | ||
containerInstanceResourceGroup: 'io-p-rg-common' | ||
containerInstanceVNet: 'io-p-vnet-common' | ||
containerInstanceSubnet: 'azure-devops' | ||
|
||
# Promote the staging instance to production | ||
- stage: Deploy_production | ||
dependsOn: | ||
- Healthcheck | ||
- Deploy_staging | ||
jobs: | ||
- job: 'do_deploy' | ||
steps: | ||
- task: AzureAppServiceManage@0 | ||
inputs: | ||
azureSubscription: '$(PRODUCTION_AZURE_SUBSCRIPTION)' | ||
resourceGroupName: '$(PRODUCTION_RESOURCE_GROUP_NAME)' | ||
webAppName: '$(PRODUCTION_APP_NAME)' | ||
sourceSlot: staging | ||
swapWithProduction: true | ||
displayName: Swap with production slot |
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,15 @@ | ||
*.js.map | ||
*.ts | ||
.git* | ||
.vscode* | ||
.circleci* | ||
.prettierrc | ||
local.settings.json* | ||
tsconfig.json | ||
tslint.json | ||
README.md | ||
yarn.lock | ||
jest.config.js | ||
__* | ||
Dangerfile.js | ||
CODEOWNERS |
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,57 @@ | ||
bin | ||
obj | ||
csx | ||
.vs | ||
edge | ||
Publish | ||
|
||
*.user | ||
*.suo | ||
*.cscfg | ||
*.Cache | ||
project.lock.json | ||
|
||
/packages | ||
/TestResults | ||
|
||
/tools/NuGet.exe | ||
/App_Data | ||
/secrets | ||
/data | ||
.secrets | ||
appsettings.json | ||
local.settings.json | ||
|
||
node_modules | ||
dist | ||
|
||
# Local python packages | ||
.python_packages/ | ||
|
||
# Python Environments | ||
.env | ||
.venv | ||
env/ | ||
venv/ | ||
ENV/ | ||
env.bak/ | ||
venv.bak/ | ||
|
||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
coverage | ||
|
||
yarn-error.log | ||
|
||
generated | ||
*.zip | ||
|
||
*.js | ||
!jest.config.js | ||
!.release-it.js | ||
|
||
|
||
azure-functions-core-tools |
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 @@ | ||
12.19.1 |
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 @@ | ||
12.19.1 |
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,2 @@ | ||
# .prettierrc | ||
parser: typescript |
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,5 @@ | ||
{ | ||
"recommendations": [ | ||
"ms-azuretools.vscode-azurefunctions" | ||
] | ||
} |
Oops, something went wrong.