aboutsummaryrefslogtreecommitdiffstats
path: root/.github/workflows/ci.yaml
blob: 5bf2fdbf90996df66ffdc60ad582b7a7a7e816f4 (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
permissions:
  contents: read
on:
  push:
    branches: [master]
  pull_request:

concurrency:
  group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
  cancel-in-progress: true

name: ci

jobs:
  os-check:
    runs-on: ${{ matrix.os }}
    name: ${{ matrix.os }} / stable
    strategy:
      fail-fast: false
      matrix:
        os: [macos-latest, windows-latest]
    steps:
      - uses: actions/checkout@v5
        with:
          submodules: true
      - name: Install stable
        uses: dtolnay/rust-toolchain@stable
      - name: Install protoc
        uses: arduino/setup-protoc@v3
        with:
          repo-token: ${{ secrets.GITHUB_TOKEN }}
      - name: Install cargo-nextest
        uses: taiki-e/install-action@v2
        with:
          tool: cargo-nextest
      - uses: Swatinem/rust-cache@v2
      - name: cargo test --workspace
        run: cargo nextest run --no-run --workspace --locked --all-features --all-targets
      - name: cargo build
        run: cargo build --workspace --locked --all-features --all-targets

  dockerfile:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: true
      matrix:
        crate:
          - pseudonyms
          - warden
          - configuration
          - router
          - rule-executor
          - aggregator
    name: dockerfile / ${{ matrix.crate }}
    steps:
      - uses: actions/checkout@v5
        with:
          submodules: true
      - name: Set up docker buildx
        uses: docker/setup-buildx-action@v3
      - name: Build # and push
        uses: docker/build-push-action@v6
        with:
          push: false
          context: .
          file: crates/${{ matrix.crate }}/Dockerfile
          tags: warden/${{ matrix.crate }}:latest
          cache-from: type=gha
          cache-to: type=gha,mode=max
          outputs: type=docker,dest=/tmp/${{ matrix.crate }}.tar
      - name: Upload artifact
        uses: actions/upload-artifact@v4
        with:
          name: warden-${{ matrix.crate }}
          path: /tmp/${{ matrix.crate }}.tar

  msrv:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        msrv: ["1.89.0"]
    name: msrv / ${{ matrix.msrv }}
    steps:
      - uses: actions/checkout@v5
        with:
          submodules: true
      - name: Install ${{ matrix.msrv }}
        uses: dtolnay/rust-toolchain@master
        with:
          toolchain: ${{ matrix.msrv }}
      - name: Install protoc
        uses: arduino/setup-protoc@v3
        with:
          repo-token: ${{ secrets.GITHUB_TOKEN }}
      - name: cargo install cargo-hack
        uses: taiki-e/install-action@cargo-hack
      - name: cargo hack +${{ matrix.msrv }} 
        run: cargo hack --clean-per-run --feature-powerset check

  test:
    runs-on: ubuntu-latest
    needs:
      - dockerfile
      - os-check
    name: test / workspace
    steps:
      - uses: actions/checkout@v5
        with:
          submodules: true
      - name: Start stack
        run: docker compose -f contrib/docker-compose/compose.yaml up -d
      - name: Setup node.js
        uses: actions/setup-node@v4
        with:
          node-version: '20'
      - name: Download artifacts
        uses: actions/download-artifact@v5
        with:
          path: warden-images
          pattern: warden-*
          merge-multiple: true
      - name: Load docker images
        run: |
          dir="warden-images"
          for file in "$dir"/*.tar; do
            if [ -f "$file" ]; then
              echo "Loading tar: $file"
              image_name=$(docker load --input "$file" | awk '/Loaded image:/ {print $3}')
              echo "Running image: $image_name"
              docker run --rm -d --network host "$image_name"
            fi
          done
          echo "images loaded"
          docker image ls -a
      - name: Install bruno cli
        run: npm install -g @usebruno/cli
      - name: Run HTTP-api tests
        run: |
          cd contrib/bruno
          bru run configuration/health-check.bru \
            configuration/routing/02-post-routing.bru \
            configuration/rule/01-create.bru \
            configuration/typology/01-create.bru \
            --env warden --reporter-html results.html
      - name: Upload test results
        uses: actions/upload-artifact@v4
        with:
          name: test-results
          path: contrib/bruno/results.html
      - name: Install stable
        uses: dtolnay/rust-toolchain@stable
        with:
          components: llvm-tools-preview
      - uses: taiki-e/install-action@cargo-llvm-cov
      - name: Install cargo-nextest
        uses: taiki-e/install-action@v2
        with:
          tool: cargo-nextest
      - uses: Swatinem/rust-cache@v2
      - name: Install protoc
        uses: arduino/setup-protoc@v3
        with:
          repo-token: ${{ secrets.GITHUB_TOKEN }}
      - name: Prepare environment for tests
        run: |
          for processor in warden pseudonyms aggregator configuration; do
            cp crates/$processor/.env.example crates/$processor/.env
          done
      - name: Collect coverage data
        # Generate separate reports for nextest and doctests, and combine them.
        run: |
          cargo llvm-cov nextest --workspace --locked --all-features --lcov --output-path lcov.info
          # switch to nightly
          # cargo llvm-cov --no-report nextest
          # cargo llvm-cov --no-report --doc
          # cargo llvm-cov report --doctests --lcov --output-path lcov.info
      - name: Upload coverage reports to Codecov
        uses: codecov/codecov-action@v5
        with:
          token: ${{ secrets.CODECOV_TOKEN }}
          files: lcov.info
      - name: Stop stack
        if: always()
        run: |
          docker compose -f contrib/docker-compose/compose.yaml down -v
          docker stop $(docker ps -aq) || true
          docker rm $(docker ps -aq) || true