File: ci-test.yml

package info (click to toggle)
nerdlog 1.10.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,296 kB
  • sloc: sh: 1,004; makefile: 85
file content (123 lines) | stat: -rw-r--r-- 3,815 bytes parent folder | download
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
name: ci-test

on:
  push: # Run on push to any branch

jobs:
  test-ubuntu:
    name: Tests (Ubuntu)
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v4
      - name: Set up Go
        uses: actions/setup-go@v5
        with:
          go-version: stable

      - name: Install deps
        run: |
          sudo apt install -y libx11-dev

      - name: Run tests
        run: make test

  test-freebsd:
    name: Tests (FreeBSD)
    # Sadly GitHub doesn't support FreeBSD runners natively, so we
    # run Ubuntu and then start FreeBSD VM.
    # See https://github.com/vmactions/freebsd-vm
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Run tests in FreeBSD VM
        uses: vmactions/freebsd-vm@v1
        with:
          usesh: true
          prepare: |
            pkg install -y go git bash gawk tmux

          run: |
            # Without it, git doesn't like to work with this repo:
            #   fatal: detected dubious ownership in repository at '....'
            # So here we work it around by marking the directory as safe.
            git config --global --add safe.directory "${PWD}"

            make test

  test-macos:
    name: Tests (MacOS)
    runs-on: macos-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v4
      - name: Set up Go
        uses: actions/setup-go@v5
        with:
          go-version: stable

      - name: Install deps
        run: |
          brew update
          brew install gawk tmux

      - name: Run tests
        run: make test

  test-ubuntu-ssh:
    name: Core tests via SSH
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      # NOTE: we do NOT use the actions/setup-go@v5 here and just use the
      # Go version installed by default, because otherwise this newly installed
      # Go version is only available in the local session, but not available
      # over ssh, which causes the build cache not to be reused, which renders
      # our trick to prebuild the journalctl_mock useless (see in Makefile:
      # cd cmd/journalctl_mock && go build -o /dev/null ), which causes the mock
      # build to take too long, which causes the tests to time out and fail.

      - name: Install deps
        run: |
          sudo apt install -y libx11-dev

      - name: Set up ssh server
        run: |
          sudo systemctl start ssh
          sudo systemctl status ssh

          # Set up the ssh key to be able to ssh 127.0.0.1 without password
          mkdir -p ~/.ssh
          ssh-keygen -t rsa -N "" -f ~/.ssh/id_rsa
          cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
          chmod 600 ~/.ssh/authorized_keys
          chmod 700 ~/.ssh
          ssh-keyscan -H 127.0.0.1 >> ~/.ssh/known_hosts

          # Test it
          goroot_local="$(go env GOROOT)"
          goroot_ssh="$(ssh 127.0.0.1 'go env GOROOT')"
          echo "GOROOT local: $goroot_local"
          echo "GOROOT ssh:   $goroot_ssh"
          if [[ "$goroot_local" != "$goroot_ssh" ]]; then
            echo Error: GOROOT are different, it might cause issues
            exit 1
          else
            echo GOROOT are the same both locally and over ssh, all good
          fi

      - name: Run core tests using ssh transport
        run: |
          # Add the key to agent, since that's what Nerdlog uses
          eval "$(ssh-agent -s)"
          ssh-add ~/.ssh/id_rsa

          echo "Running tests with ssh-lib"
          NERDLOG_CORE_TEST_HOSTNAME='127.0.0.1' make test ARGS='-run TestCoreScenarios'

          echo "Running tests with ssh-bin"
          NERDLOG_CORE_TEST_HOSTNAME='127.0.0.1' NERDLOG_CORE_TEST_TRANSPORT_SSH_BIN=1 make test ARGS='-run TestCoreScenarios'