summaryrefslogtreecommitdiffstats
path: root/.forgejo/workflows/test.yml
blob: 6cf9ddb175f46af8657b09947343d12bbecc6969 (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
name: checks
on:
  push:
    branches:
      - 'main'
  pull_request:

env:
  GOPROXY: https://goproxy.io,direct
  GOPATH: /go_path
  GOCACHE: /go_cache

jobs:
  unit:
    runs-on: docker
    container:
      image: 'code.forgejo.org/oci/node:20-bookworm'
    steps:
      - name: cache go path
        id: cache-go-path
        uses: https://code.forgejo.org/actions/cache@v4
        with:
          path: /go_path
          key: go_path-${{ github.repository }}-${{ github.ref_name }}
          restore-keys: |
            go_path-${{ github.repository }}-
            go_path-
      - name: cache go cache
        id: cache-go-cache
        uses: https://code.forgejo.org/actions/cache@v4
        with:
          path: /go_cache
          key: go_cache-${{ github.repository }}-${{ github.ref_name }}
          restore-keys: |
            go_cache-${{ github.repository }}-
            go_cache-

      - uses: https://code.forgejo.org/actions/checkout@v4

      - uses: https://code.forgejo.org/actions/setup-go@v5
        with:
          go-version-file: go.mod

      - name: validate go version
        run: |
          set -ex
          toolchain=$(grep -oP '(?<=toolchain ).+' go.mod)
          version=$(go version | cut -d' ' -f3)
          if [ "$toolchain" != "$version" ]; then
            echo "go version mismatch: $toolchain <> $version"
            exit 1
          fi

      - run: make lint-go
      - name: vet checks
        run: go vet -v ./...
      - name: build
        run: go build -v ./...
      - name: build without docker
        run: go build -tags WITHOUT_DOCKER -v ./...
      - name: unit test
        run: go test -short -v ./pkg/container ./pkg/jobparser ./pkg/model ./pkg/exprparser

  integration:
    runs-on: lxc-bookworm
    needs: [unit]
    steps:
      - uses: https://code.forgejo.org/actions/checkout@v4

      - uses: https://code.forgejo.org/actions/setup-go@v5
        with:
          go-version-file: go.mod

      - name: apt install docker.io
        run: |
          export DEBIAN_FRONTEND=noninteractive
          apt-get update -qq
          apt-get -q install -qq -y docker.io

      - name: integration test
        run: go test -run=TestRunSkipped -v ./pkg/runner