forked from rinsuki/sea
-
Notifications
You must be signed in to change notification settings - Fork 0
/
azure-pipelines.yml
71 lines (68 loc) · 2.86 KB
/
azure-pipelines.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# Node.js
# Build a general Node.js project with npm.
# Add steps that analyze code, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/javascript
trigger:
- master
- greenkeeper/*
pool:
vmImage: "Ubuntu-16.04"
steps:
- script: |
docker run --name postgres -e POSTGRES_PASSWORD=onlyfortesting -d postgres:10-alpine
displayName: "Run PostgreSQL"
- script: |
docker pull rinsuki/sea:latest
displayName: "Fetch previous build result"
- script: |
docker build --cache-from rinsuki/sea:latest -t rinsuki/sea:latest .
displayName: "Build docker container"
- script: |
docker run --rm --link postgres:postgres -e DATABASE_URL="postgres://postgres:onlyfortesting@postgres/postgres" rinsuki/sea yarn migration:up
displayName: "Run yarn migration:up"
- script: |
docker run --rm --link postgres:postgres --env-file ./ci-files/.env -e DATABASE_URL="postgres://postgres:onlyfortesting@postgres/postgres" -v $(pwd)/coverage:/app/coverage rinsuki/sea sh -c 'yarn test --coverage --coverageReporters=cobertura --coverageReporters=html'
displayName: "Run yarn test"
- script: |
sudo chown vsts ./coverage/cobertura-coverage.xml
python3 -c 'import os;r=open("./coverage/cobertura-coverage.xml", "r").read().replace("/app", os.getcwd());open("./coverage/cobertura-coverage.xml", "w").write(r)'
- task: PublishCodeCoverageResults@1
inputs:
codeCoverageTool: cobertura
summaryFileLocation: $(System.DefaultWorkingDirectory)/coverage/cobertura-coverage.xml
- script: |
docker run --rm --link postgres:postgres -e DATABASE_URL="postgres://postgres:onlyfortesting@postgres/postgres" rinsuki/sea yarn migration:downall
displayName: "Run yarn migration:downall"
- task: Docker@2
displayName: "Login to DockerHub"
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
inputs:
command: login
containerRegistry: dockerHub
- task: Docker@2
displayName: "Push to DockerHub"
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
inputs:
command: push
repository: rinsuki/sea
tags: latest
containerRegistry: dockerHub
- task: Docker@2
displayName: "Log-out from DockerHub"
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
inputs:
command: logout
containerRegistry: dockerHub
- task: JenkinsQueueJob@2
displayName: "Deploy"
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
inputs:
serverEndpoint: jenkins
jobName: sea-sns
captureConsole: false
- script: |
curl -s https://codecov.io/bash -o .codecov && chmod +x .codecov
./.codecov
env:
CODECOV_TOKEN: $(codecovToken)
displayName: Upload Code Coverage to codecov