-
Notifications
You must be signed in to change notification settings - Fork 19
130 lines (108 loc) · 3.55 KB
/
ci.yml
File metadata and controls
130 lines (108 loc) · 3.55 KB
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
name: CI
on: # yamllint disable-line rule:truthy
push:
branches:
- main
pull_request:
permissions: {}
jobs:
build:
name: Build
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Check out code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Test
run: script/test
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
lint:
name: Lint
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Install Go
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version-file: go.mod
# yamllint is pre-installed on GitHub Actions runners:
# https://github.com/adrienverge/yamllint/pull/588
- run: yamllint .
- run: go mod tidy -diff
- name: Ensure gofmt passes
run: |
UNFORMATTED=$(gofmt -l . | grep -v '^vendor/' || true) # gofmt doesn't ignore the `vendor` folder
if [ -n "$UNFORMATTED" ]; then
echo "$UNFORMATTED" | xargs gofmt -d
exit 1
fi
- run: go build ./... # gives better error messages then go vet when the build fails, and go vet will reuse the build cache
- run: go vet ./...
# The `github/codeql-action/start-proxy` action uses native binaries for
# Linux, macOS, and Windows.
build-codeql:
name: Build (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Install Go
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version-file: go.mod
- name: Build
shell: bash
run: |
if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
go build -o dependabot-proxy.exe .
else
go build -o dependabot-proxy .
fi
env:
CGO_ENABLED: 0
- name: Set output name
id: platform
shell: bash
run: |
if [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then
echo "name=linux64" >> $GITHUB_OUTPUT;
elif [[ "${{ matrix.os }}" == "macos-latest" ]]; then
echo "name=osx64" >> $GITHUB_OUTPUT;
elif [[ "${{ matrix.os }}" == "windows-latest" ]]; then
echo "name=win64" >> $GITHUB_OUTPUT;
fi
- name: Compress binary artifact
shell: bash
env:
PLATFORM_NAME: ${{ steps.platform.outputs.name }}
run: |
if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
tar -czvf dependabot-proxy-win64.tar.gz dependabot-proxy.exe;
else
tar -czvf "dependabot-proxy-${PLATFORM_NAME}.tar.gz" dependabot-proxy;
fi
- name: Upload binary artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
path: dependabot-proxy-${{ steps.platform.outputs.name }}.tar.gz
name: dependabot-proxy-${{ steps.platform.outputs.name }}