summaryrefslogtreecommitdiffstats
path: root/.github/workflows/ci.yml
blob: 22c80df9c153121cce7ddee8038994783419d2e0 (plain)
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
name: CI

on:
  schedule:
    - cron: '0 2 * * *' # run at 2 AM UTC
  push:
    branches: [ '*' ]
  pull_request:
    branches: [ master ]

env:
  CARGO_TERM_COLOR: always

jobs:
  build:
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, macos-latest, windows-latest]
        rust: [nightly, stable, '1.65']
    runs-on: ${{ matrix.os }}
    continue-on-error: ${{ matrix.rust == 'nightly' }}

    steps:
    - uses: actions/checkout@v2

    - name: Restore cargo cache
      uses: actions/cache@v2
      env:
        cache-name: ci
      with:
        path: |
          ~/.cargo/registry
          ~/.cargo/git
          ~/.cargo/bin
          target
        key: ${{ matrix.os }}-${{ env.cache-name }}-${{ matrix.rust }}-${{ hashFiles('Cargo.lock') }}

    - name: MacOS Workaround
      if: matrix.os == 'macos-latest'
      run: cargo clean -p serde_derive -p thiserror

    - name: Install Rust
      uses: actions-rs/toolchain@v1
      with:
        toolchain: ${{ matrix.rust }}
        default: true
        override: true
        profile: minimal
        components: clippy

    - name: Build Debug
      run: |
        cargo build

    - name: Run tests
      run: make test

    - name: Run clippy
      run: |
        make clippy

    - name: Build Release
      run: make build-release

    - name: Test Install
      run: cargo install --path "." --force

    - name: Binary Size (unix)
      if: matrix.os != 'windows-latest'
      run: |
        ls -l ./target/release/gitui

    - name: Binary Size (win)
      if: matrix.os == 'windows-latest'
      run: |
        ls -l ./target/release/gitui.exe

    - name: Binary dependencies (mac)
      if: matrix.os == 'macos-latest'
      run: |
        otool -L ./target/release/gitui

    - name: Build MSI (windows)
      if: matrix.os == 'windows-latest'
      run: |
        cargo install cargo-wix --version 0.3.3
        cargo wix --version
        cargo wix -p gitui --no-build --nocapture --output ./target/wix/gitui.msi
        ls -l ./target/wix/gitui.msi

  build-linux-musl:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        rust: [nightly, stable, '1.65']
    continue-on-error: ${{ matrix.rust == 'nightly' }}
    steps:
    - uses: actions/checkout@master
    - name: Install Rust
      uses: actions-rs/toolchain@v1
      with:
        toolchain: ${{ matrix.rust }}
        profile: minimal
        default: true
        override: true
        target: x86_64-unknown-linux-musl

    - name: Setup MUSL
      run: |
        sudo apt-get -qq install musl-tools
    - name: Build Debug
      run: |
        make build-linux-musl-debug
        ./target/x86_64-unknown-linux-musl/debug/gitui --version
    - name: Build Release
      run: |
        make build-linux-musl-release
        ./target/x86_64-unknown-linux-musl/release/gitui --version
        ls -l ./target/x86_64-unknown-linux-musl/release/gitui
    - name: Test
      run: |
        make test-linux-musl
    - name: Test Install
      run: cargo install --path "." --force

  build-linux-arm:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        rust: [nightly, stable, '1.65']
    continue-on-error: ${{ matrix.rust == 'nightly' }}
    steps:
    - uses: actions/checkout@master
    - name: Install Rust
      uses: actions-rs/toolchain@v1
      with:
        toolchain: ${{ matrix.rust }}
        profile: minimal
        default: true
        override: true
    - name: Setup ARM toolchain
      run: |
        rustup target add aarch64-unknown-linux-gnu
        rustup target add armv7-unknown-linux-gnueabihf
        rustup target add arm-unknown-linux-gnueabihf

        curl -o $GITHUB_WORKSPACE/aarch64.tar.xz https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu-a/8.2-2018.08/gcc-arm-8.2-2018.08-x86_64-aarch64-linux-gnu.tar.xz
        curl -o $GITHUB_WORKSPACE/arm.tar.xz https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu-a/8.2-2018.08/gcc-arm-8.2-2018.08-x86_64-arm-linux-gnueabihf.tar.xz

        tar xf $GITHUB_WORKSPACE/aarch64.tar.xz
        tar xf $GITHUB_WORKSPACE/arm.tar.xz

        echo "$GITHUB_WORKSPACE/gcc-arm-8.2-2018.08-x86_64-aarch64-linux-gnu/bin" >> $GITHUB_PATH
        echo "$GITHUB_WORKSPACE/gcc-arm-8.2-2018.08-x86_64-arm-linux-gnueabihf/bin" >> $GITHUB_PATH

    - name: Build Debug
      run: |
        make build-linux-arm-debug
    - name: Build Release
      run: |
        make build-linux-arm-release
        ls -l ./target/aarch64-unknown-linux-gnu/release/gitui || ls -l ./target/armv7-unknown-linux-gnueabihf/release/gitui || ls -l ./target/arm-unknown-linux-gnueabihf/release/gitui

  linting:
    name: Lints
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@master
    - name: Install Rust
      uses: actions-rs/toolchain@v1
      with:
        toolchain: stable
        override: true
        components: rustfmt

    - run: cargo fmt -- --check

    - name: cargo-sort
      run: |
        cargo install cargo-sort --force
        cargo sort -c -w

    - name: cargo-deny install
      run: |
        cargo install --locked cargo-deny

    - name: cargo-deny licenses
      run: |
        cargo deny check licenses

    - name: cargo-deny bans
      run: |
        cargo deny check bans

  udeps:
    name: udeps
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@master
    - name: Install Rust
      uses: actions-rs/toolchain@v1
      with:
        toolchain: nightly
        override: true
        
    - name: cargo-udeps
      run: |
        # cargo install --locked cargo-udeps
        cargo install --git https://github.com/est31/cargo-udeps --locked
        cargo +nightly udeps --all-targets


  sec:
    name: Security audit
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - uses: actions-rs/audit-check@v1
      with:
        token: ${{ secrets.GITHUB_TOKEN }}

  log-test:
    name: Changelog Test
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@master
    - name: Extract release notes
      id: extract_release_notes
      uses: ffurrer2/extract-release-notes@v1
      with:
        release_notes_file: ./release-notes.txt
    - uses: actions/upload-artifact@v1
      with:
        name: release-notes.txt
        path: ./release-notes.txt