Skip to content

Commit

Permalink
[#175476527] Refactor pipeline / 2 (#121)
Browse files Browse the repository at this point in the history
  • Loading branch information
balanza authored Dec 3, 2020
1 parent 00282ec commit f71f909
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 44 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
# Azure DevOps pipeline template used to checkout, install node dependencies and build the code.
# Azure DevOps pipeline template used to setup the Node project:
# 1. checkout code
# 2. setup correct node version
# 3. install node dependencies

parameters:
- name: 'make'
type: string
default: install_dependencies
values:
- install_dependencies
- build
- predeploy_build

- name: 'cache_version_id'
type: string
default: $(CACHE_VERSION_ID)
Expand All @@ -22,36 +17,29 @@ 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: Cache@2
inputs:
key: 'yarn-${{ parameters.cache_version_id }} | "$(Agent.OS)" | yarn.lock'
restoreKeys: |
yarn-${{ parameters.cache_version_id }} | "$(Agent.OS)"
path: $(YARN_CACHE_FOLDER)
cacheHitVar: 'CACHE_RESTORED'
displayName: 'Cache yarn packages'


- task: UseNode@1
inputs:
version: $(NODE_VERSION)
displayName: 'Set up Node.js'

# 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'

- script: |
yarn install --frozen-lockfile --no-progress --non-interactive --network-concurrency 1
displayName: 'Install node modules'
condition: ne(variables.CACHE_RESTORED, 'true')

- ${{ if eq(parameters.make, 'build') }}:
- bash: yarn build
displayName: 'Build code'

- ${{ if eq(parameters.make, 'predeploy_build') }}:
- bash: yarn predeploy
displayName: 'Predeploy build code'
25 changes: 8 additions & 17 deletions .devops/code-review-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,29 +28,25 @@ stages:
# As we deploy on Wondows machines, we use Windows to build
vmImage: 'windows-2019'
steps:
- template: azure-templates/make-build-steps.yml
parameters:
make: build
- template: azure-templates/setup-project.yml
- script: |
yarn build
displayName: 'Build'
- stage: Static_analysis
dependsOn: []
jobs:

- job: lint
steps:
- template: azure-templates/make-build-steps.yml
parameters:
make: install_dependencies
- template: azure-templates/setup-project.yml
- script: |
yarn lint
displayName: 'Lint'
- job: validate_api_specification
steps:
- template: azure-templates/make-build-steps.yml
parameters:
make: install_dependencies

- template: azure-templates/setup-project.yml
- script: |
yarn lint-api
displayName: 'Validate API specification'
Expand All @@ -62,10 +58,7 @@ stages:
ne(variables['DANGER_GITHUB_API_TOKEN'], 'skip')
)
steps:
- template: azure-templates/make-build-steps.yml
parameters:
make: install_dependencies

- template: azure-templates/setup-project.yml
- bash: |
yarn danger ci
env:
Expand All @@ -79,9 +72,7 @@ stages:
jobs:
- job: unit_tests
steps:
- template: azure-templates/make-build-steps.yml
parameters:
make: install_dependencies
- template: azure-templates/setup-project.yml

- script: |
yarn generate
Expand Down
9 changes: 6 additions & 3 deletions .devops/deploy-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ resources:
- repository: pagopaCommons
type: github
name: pagopa/azure-pipeline-templates
ref: refs/tags/v3
ref: refs/tags/v4
endpoint: 'pagopa'

stages:
Expand Down Expand Up @@ -82,7 +82,7 @@ stages:
- job: 'prepare_artifact_and_deploy'
steps:
# Build application
- template: azure-templates/make-build-steps.yml
- template: azure-templates/setup-project.yml
parameters:
make: predeploy_build
# On the assumption that this stage is executed only when Relase stage is,
Expand All @@ -91,7 +91,10 @@ stages:
# 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:
Expand Down

0 comments on commit f71f909

Please sign in to comment.