summaryrefslogtreecommitdiff
path: root/.github/workflows/ci.yml
blob: 60efa14968c2a99ed7d1e27003a13922a1abbbbe (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
name: continuous integration

on:
  push:
    paths:
      - 'src/*.cpp'
      - '.clang-format'
      - 'Makefile'
      - '.github/**'
  workflow_dispatch:
  pull_request:
    paths:
      - 'src/*.cpp'
      - 'src/*.hpp'

permissions:
    contents: write
    pull-requests: write

jobs:
  gcc:
    if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork
    name: "Build (Arch)"
    runs-on: ubuntu-latest
    container:
      image: archlinux
    steps:
      - name: Install dependencies
        run: |
          pacman -Syu --noconfirm
          pacman -S --noconfirm base-devel git make ninja gcc clang

      - name: Checkout repository
        uses: actions/checkout@v4
        with:
          ref: ${{ github.head_ref }}
          ssh-key: ${{ secrets.DEPLOY_KEY }}
          fetch-depth: 0

      - name: Build project
        run: |
          make all

      - name: Upload Artifact
        if: success()
        uses: actions/upload-artifact@v4
        with:
          name: chat-server
          path: build/chat-server

  clang:
    if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork
    name: "Build with Clang (Arch)"
    runs-on: ubuntu-latest
    container:
      image: archlinux
    steps:
      - name: Install dependencies
        run: |
          pacman -Syu --noconfirm
          pacman -S --noconfirm base-devel git make ninja clang llvm clang

      - name: Checkout repository
        uses: actions/checkout@v4
        with:
          ref: ${{ github.head_ref }}
          ssh-key: ${{ secrets.DEPLOY_KEY }}
          fetch-depth: 0

      - name: Build project
        run: |
          CXX=clang++ make all

  clang-format:
    if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork
    name: "Code Style (Arch)"
    runs-on: ubuntu-latest
    container:
      image: archlinux
    steps:
      - name: Install dependencies
        run: |
          pacman -Syu --noconfirm
          pacman -S --noconfirm make clang git

      - name: Checkout repository
        uses: actions/checkout@v4
        with:
          ref: ${{ github.head_ref }}
          ssh-key: ${{ secrets.DEPLOY_KEY }}
          fetch-depth: 0

      - name: Run clang-format
        run: make clang-format

      - name: Configure Git
        run: git config --global --add safe.directory '*'

      - name: Push changes
        uses: stefanzweifel/git-auto-commit-action@v5
        with:
          commit_message: "style: clang-format"
          commit_user_name: "github-actions[bot]"
          commit_user_email: "github-actions[bot]@users.noreply.github.com"
          commit_author: "github-actions[bot] <github-actions[bot]@users.noreply.github.com>"

  clang-tidy:
    if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork
    name: "Static Analysis (Arch)"
    runs-on: ubuntu-latest
    container:
      image: archlinux
    steps:
      - name: Install dependencies
        run: |
          pacman -Syu --noconfirm
          pacman -S --noconfirm make clang git

      - name: Checkout repository
        uses: actions/checkout@v4
        with:
          ref: ${{ github.head_ref }}
          ssh-key: ${{ secrets.DEPLOY_KEY }}
          fetch-depth: 0

      - name: Run clang-tidy
        run: make clang-tidy || true

      - name: Configure Git
        run: git config --global --add safe.directory '*'

      - name: Push changes
        uses: stefanzweifel/git-auto-commit-action@v5
        with:
          commit_message: "style: clang-tidy"
          commit_user_name: "github-actions[bot]"
          commit_user_email: "github-actions[bot]@users.noreply.github.com"
          commit_author: "github-actions[bot] <github-actions[bot]@users.noreply.github.com>"