-
Notifications
You must be signed in to change notification settings - Fork 10
134 lines (129 loc) · 4.1 KB
/
go.yml
File metadata and controls
134 lines (129 loc) · 4.1 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
131
132
133
134
on: push
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
- name: Build CLI for Linux
run: |
GOOS=linux GOARCH=amd64 go build -o cli-v2-linux ./cli-v2.go
- name: Build CLI for Windows
run: |
GOOS=windows GOARCH=amd64 go build -o cli-v2.exe ./cli-v2.go
- name: Build CLI for macOS
run: |
GOOS=darwin GOARCH=amd64 go build -o cli-v2-macos ./cli-v2.go
- name: Upload CLI binaries
uses: actions/upload-artifact@v4
with:
name: cli-binaries
path: |
cli-v2-linux
cli-v2.exe
cli-v2-macos
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
- name: Install dependencies from .codacy/codacy.yaml
run: |
go build ./cli-v2.go
./cli-v2 install
- name: "Run tests"
run: |
go test -coverprofile=unit.coverage.out ./...
- name: "Upload coverage to Codacy"
env:
CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }}
run: |
bash <(curl -Ls https://coverage.codacy.com/get.sh) report --force-coverage-parser go -r unit.coverage.out
ittest:
needs: build
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download CLI binaries
uses: actions/download-artifact@v4
with:
name: cli-binaries
path: .
- name: Select correct binary
shell: bash
run: |
if [ "${{ matrix.os }}" = "windows-latest" ]; then
# Keep the .exe extension for Windows
echo "Using Windows binary with .exe extension"
elif [ "${{ matrix.os }}" = "macos-latest" ]; then
mv cli-v2-macos cli-v2
else
mv cli-v2-linux cli-v2
fi
- name: Make binary executable
if: matrix.os != 'windows-latest'
run: chmod +x cli-v2
- name: Debug Windows binary
if: matrix.os == 'windows-latest'
run: |
dir
echo "Binary exists check:"
if (Test-Path cli-v2.exe) { Write-Host "Binary exists" } else { Write-Host "Binary not found" }
- name: Setup Node.js for Windows
if: matrix.os == 'windows-latest'
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies from .codacy/codacy.yaml
if: matrix.os != 'windows-latest'
run: |
./cli-v2 install
- name: Install dependencies from .codacy/codacy.yaml (Windows)
if: matrix.os == 'windows-latest'
shell: pwsh
run: |
Get-ChildItem
Write-Host "Current directory contents:"
dir
Write-Host "Node.js version:"
node --version
Write-Host "Attempting to run CLI..."
.\cli-v2.exe install
release:
needs: [test, ittest]
if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch) && github.event_name == 'push'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v4
- name: "Git Version"
id: generate-version
uses: codacy/git-version@2.8.0
- name: "Tag version"
run: |
git tag ${{ steps.generate-version.outputs.version }}
git push --tags "https://codacy:${{ secrets.GITHUB_TOKEN }}@github.com/codacy/codacy-cli-v2"
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser
# 'latest', 'nightly', or a semver
version: "latest"
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}