Skip to content

Commit

Permalink
Refactor azure pipeline configuration (#76)
Browse files Browse the repository at this point in the history
* Refactor Azure pipeline config files

- add template for steps in common
- remove test/lint from merge pipeline

* Improve display names

* Restore original file name for Azure Github app compatibility
  • Loading branch information
ThunderDev1 authored Jan 16, 2020
1 parent 711570e commit 44471ed
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 78 deletions.
64 changes: 0 additions & 64 deletions .azure/client-build-pipeline.yml

This file was deleted.

13 changes: 13 additions & 0 deletions .azure/install-steps.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
parameters:
clientFolder: 'client'

steps:
- task: NodeTool@0
inputs:
versionSpec: '10.x'
displayName: 'Install Node.js'

- script: |
yarn install
workingDirectory: ${{ parameters.clientFolder }}
displayName: 'Install dependencies'
44 changes: 44 additions & 0 deletions .azure/merge-pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
variables:
clientFolder: client

trigger:
branches:
include:
- 'master'

pr:
branches:
exclude:
- '*'

jobs:
- job: merge_pipeline
displayName: Client app production build & deploy
pool:
vmImage: 'ubuntu-latest'
steps:
- template: install-steps.yml
parameters:
clientFolder: $(clientFolder)

- script: yarn build
workingDirectory: $(clientFolder)
displayName: 'Build project'

- task: ArchiveFiles@2
inputs:
rootFolderOrFile: '$(clientFolder)/build'
archiveType: 'zip'
archiveFile: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip'
replaceExistingArchive: true
displayName: 'Create zip archive'

- script: >-
curl
-H 'Authorization: Bearer $(netlifyAccessToken)'
-H 'Content-Type: application/zip'
--data-binary '@$(Build.BuildId).zip'
https://api.netlify.com/api/v1/sites/$(netlifySiteId)/deploys
workingDirectory: '$(Build.ArtifactStagingDirectory)'
displayName: 'Upload to Netlify'
23 changes: 9 additions & 14 deletions .azure/azure-pipelines.yml → azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -1,57 +1,52 @@
# Node.js with React
# Build a Node.js project that uses React.
# Add steps that analyze code, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/javascript
# PR pipeline, needs to be in a file named azure-pipelines.yml, located at the root of the projet..

variables:
clientFolder: client

# Disabled CI on every branches...
trigger:
branches:
exclude:
- '*'

# ...but enable CI on every PRs
pr:
branches:
include:
- '*'

jobs:
- job: client_testing
displayName: Client App Testing
displayName: Client app testing
pool:
vmImage: 'ubuntu-latest'
steps:
- task: NodeTool@0
inputs:
versionSpec: '10.x'
displayName: 'Install Node.js'
- template: /.azure/install-steps.yml
parameters:
clientFolder: $(clientFolder)

- script: |
yarn install
yarn add -D jest-junit
workingDirectory: $(clientFolder)
displayName: 'Install dependencies'
displayName: 'Install test reporter'
- script : |
yarn lint
yarn lint:style
workingDirectory: $(clientFolder)
displayName: 'Lint code'
displayName: 'Lint code and styles'
- script: CI=true yarn test --reporters=default --reporters=jest-junit --coverage --coverageReporters=cobertura
workingDirectory: $(clientFolder)
displayName: 'Run tests'

- task: PublishTestResults@2
displayName: 'Publish test results'
condition: succeededOrFailed()
inputs:
testRunner: JUnit
testResultsFiles: '$(clientFolder)/junit.xml'

- task: PublishCodeCoverageResults@1
displayName: 'Publish code coverage results'
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: '$(clientFolder)/coverage/*coverage.xml'

0 comments on commit 44471ed

Please sign in to comment.