Skip to content

Commit c2ff9c0

Browse files
authored
feat(ci):add schedule main with sonar (#103)
This pull request introduces a new GitHub Actions workflow to automate daily scheduled tasks, including linting, testing, and SonarQube scanning for the main branch. The workflow is designed to ensure code quality and maintainability by leveraging existing reusable actions. ### New GitHub Actions Workflow: * **Workflow Name and Trigger**: Added a new workflow named `schedule-main` that runs once a day at 1:00 UTC using a cron schedule and can also be triggered manually via `workflow_dispatch`. (`.github/workflows/schedule-main.yml`) * **Linting Jobs**: - **Go Linting**: Configured a job (`ci-lint`) to lint Go code using `ci-lint-go` with custom arguments for compatibility with `golangci-lint` v2. (`.github/workflows/schedule-main.yml`) - **Miscellaneous Linting**: Added a job (`ci-lint-misc`) to lint YAML and shell script files using `ci-lint-misc`. (`.github/workflows/schedule-main.yml`) * **Testing Job**: Included a job (`ci-test`) to build and test the codebase using `ci-test-go`, with race detection and coverage reporting enabled. (`.github/workflows/schedule-main.yml`) * **Son
1 parent 4fd7439 commit c2ff9c0

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

.github/workflows/schedule-main.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: schedule-main
2+
3+
on:
4+
schedule:
5+
# Runs once a day at 1:00 UTC on main branch to collect statistics
6+
- cron: '0 1 * * *'
7+
workflow_dispatch:
8+
9+
jobs:
10+
ci-lint:
11+
name: Lint
12+
runs-on: ubuntu-latest
13+
permissions:
14+
id-token: write
15+
contents: read
16+
actions: read
17+
steps:
18+
- name: Linting Go
19+
uses: smartcontractkit/.github/actions/ci-lint-go@eeb76b5870e3c17856d5a60fd064a053c023b5f5 # ci-lint-go@1.0.0
20+
with:
21+
only-new-issues: "false"
22+
golangci-lint-version: v2.0.2
23+
# Override the lint args because the default ones are not compatible with golangci-lint v2
24+
golangci-lint-args: --output.checkstyle.path=golangci-lint-report.xml
25+
26+
ci-lint-misc:
27+
name: Lint GH Actions and scripts
28+
runs-on: ubuntu-latest
29+
steps:
30+
- name: Linting Misc (yaml + sh files)
31+
uses: smartcontractkit/.github/actions/ci-lint-misc@eeb76b5870e3c17856d5a60fd064a053c023b5f5 # ci-lint-misc@1.0.0
32+
33+
ci-test:
34+
name: Tests
35+
runs-on: ubuntu-latest
36+
permissions:
37+
id-token: write
38+
contents: read
39+
actions: read
40+
steps:
41+
- name: Build and test
42+
uses: smartcontractkit/.github/actions/ci-test-go@eeb76b5870e3c17856d5a60fd064a053c023b5f5 # ci-test-go@1.0.0
43+
with:
44+
go-test-cmd: go test -race -coverprofile=coverage.txt $(go list ./...)
45+
use-go-cache: true
46+
47+
sonarqube:
48+
name: Sonar Scan
49+
if: github.event_name == 'pull_request'
50+
runs-on: ubuntu-24.04
51+
needs: [ ci-test, ci-lint-misc, ci-lint ]
52+
steps:
53+
- name: Scan with Sonarqube
54+
uses: smartcontractkit/.github/actions/ci-sonarqube-go@01d931b0455a754d12e7143cc54a5a3521a8f6f6 # ci-sonarqube-go@0.3.1
55+
with:
56+
sonar-token: ${{ secrets.SONAR_TOKEN }}
57+
sonar-host-url: ${{ secrets.SONAR_HOST_URL }}

0 commit comments

Comments
 (0)