.gitlab-ci.yml 2.21 KB
Newer Older
1
image: 'rust:latest'
Robert Czechowski's avatar
Robert Czechowski committed
2
3
4
5

stages:
  - test
  - build
6
  - testdeploy
7
  - deploy
Robert Czechowski's avatar
Robert Czechowski committed
8
9
10
11
12
13

variables:
  CARGO_HOME: $CI_PROJECT_DIR/cargo
  APT_CACHE_DIR: $CI_PROJECT_DIR/apt


Robert Czechowski's avatar
Robert Czechowski committed
14

15
test:
Robert Czechowski's avatar
Robert Czechowski committed
16
17
18
19
  stage: test
  script:
    - rustc --version
    - cargo --version
20
    - cargo test --features "strict" --verbose
Robert Czechowski's avatar
Robert Czechowski committed
21
22
23
24

clippy:
  stage: test
  script:
25
    - rustup component add clippy
26
    - make clippy
Robert Czechowski's avatar
Robert Czechowski committed
27

Robert Czechowski's avatar
Robert Czechowski committed
28
29
30
31


documentation:
  stage: build
Robert Czechowski's avatar
Robert Czechowski committed
32
33
  script:
    - cargo doc --no-deps
34
    - echo '<meta http-equiv="refresh" content="0; url=medal">' > target/doc/index.html
Robert Czechowski's avatar
Robert Czechowski committed
35
36
  only:
    - master
37
    
38
39
40
41
42
43
build:
  stage: build
  script:
    - cargo build --release
  only:
    - master
44
    - deploy
Robert Czechowski's avatar
Robert Czechowski committed
45
46
47



48
49
testdeploy:
  stage: testdeploy
Robert Czechowski's avatar
Robert Czechowski committed
50
51
52
53
54
55
56
  script:   
    # Setup SSH deploy keys
    - 'which ssh-agent || ( apt-get install -qq openssh-client )'
    - eval $(ssh-agent -s)
    - ssh-add <(echo "$SSH_PRIVATE_KEY" | base64 -d)
    - mkdir -p ~/.ssh
    - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
57
    # Stop server and upload
58
59
    - ssh medald@jim.test.bwinf.de "sudo /bin/systemctl stop medal && exit"
    - "scp target/release/medal medald@jim.test.bwinf.de:medal/"
60
61
    - "scp -r migrations static templates medald@jim.test.bwinf.de:medal/"
    - "scp -r target/doc medald@jim.test.bwinf.de:medal/"
62
    - "scp -r tasks/jwinf/wrapper.html medald@jim.test.bwinf.de:medal/tasks/jwinf/"
63
    - ssh medald@jim.test.bwinf.de "sudo /bin/systemctl start medal && exit"
64
65
  only:
    - master
66
67
68
69
70
71
72
73
74
75
76
77
78
79
    - deploy



deploy:
  stage: deploy
  script:   
    # Setup SSH deploy keys
    - 'which ssh-agent || ( apt-get install -qq openssh-client )'
    - eval $(ssh-agent -s)
    - ssh-add <(echo "$SSH_PRIVATE_DEPLOY_KEY" | base64 -d)
    - mkdir -p ~/.ssh
    - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
    # Stop server and upload
80
81
82
83
84
    - ssh medald@jwinf.de "sudo /bin/systemctl stop medal && exit"
    - "scp target/release/medal medald@jwinf.de:medal/"
    - "scp -r migrations static templates medald@jwinf.de:medal/"
    - "scp -r tasks/jwinf/wrapper.html medald@jwinf.de:medal/tasks/jwinf/"
    - ssh medald@jwinf.de "sudo /bin/systemctl start medal && exit"
85
86
  only:
    - deploy
Robert Czechowski's avatar
Robert Czechowski committed
87

Robert Czechowski's avatar
Robert Czechowski committed
88
89


Robert Czechowski's avatar
Robert Czechowski committed
90
91
92
93
94
95
cache:
  paths:
    - apt/
    - cargo/
    - target/