Skip to content

Commit

Permalink
Fixing CI
Browse files Browse the repository at this point in the history
  • Loading branch information
mateusz-sekara committed Oct 24, 2024
1 parent 55098f5 commit 7e16199
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 50 deletions.
45 changes: 10 additions & 35 deletions .github/workflows/ci-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -258,66 +258,53 @@ jobs:
needs: [filter, core]
name: Flakey Test Detection
runs-on: ubuntu-latest
if: ${{ always() && github.actor != 'dependabot[bot]' }}
if: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }}
env:
CL_DATABASE_URL: postgresql://postgres:postgres@localhost:5432/chainlink_test?sslmode=disable
permissions:
id-token: write
contents: read
steps:
- name: Checkout the repo
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
uses: actions/checkout@v4.2.1
- name: Setup node
if: ${{ needs.filter.outputs.changes == 'true' }}
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
uses: actions/[email protected]
- name: Setup NodeJS
if: ${{ needs.filter.outputs.changes == 'true' }}
uses: ./.github/actions/setup-nodejs
with:
prod: "true"
- name: Setup Go
if: ${{ needs.filter.outputs.changes == 'true' }}
uses: ./.github/actions/setup-go
- name: Setup Postgres
if: ${{ needs.filter.outputs.changes == 'true' }}
uses: ./.github/actions/setup-postgres
- name: Touching core/web/assets/index.html
if: ${{ needs.filter.outputs.changes == 'true' }}
run: mkdir -p core/web/assets && touch core/web/assets/index.html
- name: Download Go vendor packages
if: ${{ needs.filter.outputs.changes == 'true' }}
run: go mod download
- name: Replace chainlink-evm deps
if: ${{ needs.filter.outputs.changes == 'true' && inputs.evm-ref != ''}}
if: ${{ github.event_name == 'workflow_dispatch' && inputs.evm-ref != ''}}
shell: bash
run: go get github.com/smartcontractkit/chainlink-integrations/evm/relayer@${{ inputs.evm-ref }}
- name: Build binary
if: ${{ needs.filter.outputs.changes == 'true' }}
run: go build -o chainlink.test .
- name: Setup DB
if: ${{ needs.filter.outputs.changes == 'true' }}
run: ./chainlink.test local db preparetest
- name: Load test outputs
if: ${{ needs.filter.outputs.changes == 'true' }}
uses: actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427 # v4.1.4
uses: actions/[email protected]
with:
name: go_core_tests_logs
path: ./artifacts
- name: Delete go_core_tests_logs/coverage.txt
if: ${{ needs.filter.outputs.changes == 'true' }}
shell: bash
run: |
# Need to delete coverage.txt so the disk doesn't fill up
rm -f ./artifacts/go_core_tests_logs/coverage.txt
- name: Build flakey test runner
if: ${{ needs.filter.outputs.changes == 'true' }}
run: go build ./tools/flakeytests/cmd/runner
- name: Re-run tests
if: ${{ needs.filter.outputs.changes == 'true' }}
env:
GRAFANA_INTERNAL_BASIC_AUTH: ${{ secrets.GRAFANA_INTERNAL_BASIC_AUTH }}
GRAFANA_INTERNAL_HOST: ${{ secrets.GRAFANA_INTERNAL_HOST }}
GRAFANA_INTERNAL_TENANT_ID: ${{ secrets.GRAFANA_INTERNAL_TENANT_ID }}
GITHUB_EVENT_PATH: ${{ github.event_path }}
GITHUB_EVENT_NAME: ${{ github.event_name }}
GITHUB_REPO: ${{ github.repository }}
Expand All @@ -334,12 +321,13 @@ jobs:
-command=./tools/bin/go_core_tests \
`ls -R ./artifacts/output.txt`
- name: Store logs artifacts
if: ${{ needs.filter.outputs.changes == 'true' && always() }}
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
if: ${{ always() }}
uses: actions/upload-artifact@v4.4.3
with:
name: flakey_test_runner_logs
path: |
./output.txt
retention-days: 7

scan:
name: SonarQube Scan
Expand All @@ -348,11 +336,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout the repo
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
uses: actions/checkout@v4.2.1
with:
fetch-depth: 0 # fetches all history for all tags and branches to provide more metadata for sonar reports
- name: Download all workflow run artifacts
uses: actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427 # v4.1.4
uses: actions/[email protected].8

- name: Check and Set SonarQube Report Paths
shell: bash
Expand Down Expand Up @@ -407,19 +395,6 @@ jobs:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
SONAR_SCANNER_OPTS: "-Xms6g -Xmx8g"

- name: Collect Metrics
if: always()
id: collect-gha-metrics
uses: smartcontractkit/push-gha-metrics-action@d9da21a2747016b3e13de58c7d4115a3d5c97935 # v3.0.1
with:
id: ci-core-sonarqube
org-id: ${{ secrets.GRAFANA_INTERNAL_TENANT_ID }}
basic-auth: ${{ secrets.GRAFANA_INTERNAL_BASIC_AUTH }}
hostname: ${{ secrets.GRAFANA_INTERNAL_HOST }}
this-job-name: SonarQube Scan
continue-on-error: true

clean:
name: Clean Go Tidy & Generate
if: ${{ !contains(join(github.event.pull_request.labels.*.name, ' '), 'skip-smoke-tests') && github.actor != 'dependabot[bot]' }}
Expand Down
7 changes: 1 addition & 6 deletions tools/flakeytests/cmd/runner/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ func main() {

grafanaHost := flag.String("grafana_host", "", "grafana host URL")
grafanaAuth := flag.String("grafana_auth", "", "grafana basic auth for Loki API")
grafanaOrgID := flag.String("grafana_org_id", "", "grafana org ID")
command := flag.String("command", "", "test command being rerun; used to tag metrics")
ghSHA := flag.String("gh_sha", "", "commit sha for which we're rerunning tests")
ghEventPath := flag.String("gh_event_path", "", "path to associated gh event")
Expand All @@ -46,10 +45,6 @@ func main() {
log.Fatal("Error re-running flakey tests: `grafana_auth` is required")
}

if *grafanaOrgID == "" {
log.Fatal("Error re-running flakey tests: `grafana_org_id` is required")
}

if *command == "" {
log.Fatal("Error re-running flakey tests: `command` is required")
}
Expand All @@ -68,7 +63,7 @@ func main() {
}

meta := flakeytests.GetGithubMetadata(*ghRepo, *ghEventName, *ghSHA, *ghEventPath, *ghRunID, runAttempt)
rep := flakeytests.NewLokiReporter(*grafanaHost, *grafanaAuth, *grafanaOrgID, *command, meta)
rep := flakeytests.NewLokiReporter(*grafanaHost, *grafanaAuth, *command, meta)
r := flakeytests.NewRunner(readers, rep, numReruns)
err := r.Run(ctx)
if err != nil {
Expand Down
6 changes: 2 additions & 4 deletions tools/flakeytests/reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ type Context struct {
type LokiReporter struct {
host string
auth string
orgId string
command string
now func() time.Time
ctx Context
Expand Down Expand Up @@ -156,7 +155,6 @@ func (l *LokiReporter) makeRequest(ctx context.Context, pushReq pushRequest) err
fmt.Sprintf("Basic %s", base64.StdEncoding.EncodeToString([]byte(l.auth))),
)
req.Header.Add("Content-Type", "application/json")
req.Header.Add("X-Scope-OrgID", l.orgId)
resp, err := http.DefaultClient.Do(req)
if err != nil {
return err
Expand All @@ -179,6 +177,6 @@ func (l *LokiReporter) Report(ctx context.Context, report *Report) error {
return l.makeRequest(ctx, pushReq)
}

func NewLokiReporter(host, auth, orgId, command string, ctx Context) *LokiReporter {
return &LokiReporter{host: host, auth: auth, orgId: orgId, command: command, now: time.Now, ctx: ctx}
func NewLokiReporter(host, auth, command string, ctx Context) *LokiReporter {
return &LokiReporter{host: host, auth: auth, command: command, now: time.Now, ctx: ctx}
}
10 changes: 5 additions & 5 deletions tools/flakeytests/reporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func TestMakeRequest_SingleTest(t *testing.T) {
},
},
}
lr := &LokiReporter{auth: "bla", host: "bla", orgId: "bla", command: "go_core_tests", now: func() time.Time { return now }}
lr := &LokiReporter{auth: "bla", host: "bla", command: "go_core_tests", now: func() time.Time { return now }}
pr, err := lr.createRequest(r)
require.NoError(t, err)
assert.Len(t, pr.Streams, 1)
Expand All @@ -41,7 +41,7 @@ func TestMakeRequest_MultipleTests(t *testing.T) {
},
},
}
lr := &LokiReporter{auth: "bla", host: "bla", orgId: "bla", command: "go_core_tests", now: func() time.Time { return now }}
lr := &LokiReporter{auth: "bla", host: "bla", command: "go_core_tests", now: func() time.Time { return now }}
pr, err := lr.createRequest(r)
require.NoError(t, err)
assert.Len(t, pr.Streams, 1)
Expand All @@ -58,7 +58,7 @@ func TestMakeRequest_NoTests(t *testing.T) {
now := time.Now()
ts := fmt.Sprintf("%d", now.UnixNano())
r := NewReport()
lr := &LokiReporter{auth: "bla", host: "bla", orgId: "bla", command: "go_core_tests", now: func() time.Time { return now }}
lr := &LokiReporter{auth: "bla", host: "bla", command: "go_core_tests", now: func() time.Time { return now }}
pr, err := lr.createRequest(r)
require.NoError(t, err)
assert.Len(t, pr.Streams, 1)
Expand All @@ -72,7 +72,7 @@ func TestMakeRequest_WithContext(t *testing.T) {
now := time.Now()
ts := fmt.Sprintf("%d", now.UnixNano())
r := NewReport()
lr := &LokiReporter{auth: "bla", host: "bla", orgId: "bla", command: "go_core_tests", now: func() time.Time { return now }, ctx: Context{CommitSHA: "42"}}
lr := &LokiReporter{auth: "bla", host: "bla", command: "go_core_tests", now: func() time.Time { return now }, ctx: Context{CommitSHA: "42"}}
pr, err := lr.createRequest(r)
require.NoError(t, err)
assert.Len(t, pr.Streams, 1)
Expand All @@ -95,7 +95,7 @@ func TestMakeRequest_Panics(t *testing.T) {
"core/assets": 1,
},
}
lr := &LokiReporter{auth: "bla", host: "bla", orgId: "bla", command: "go_core_tests", now: func() time.Time { return now }}
lr := &LokiReporter{auth: "bla", host: "bla", command: "go_core_tests", now: func() time.Time { return now }}
pr, err := lr.createRequest(r)
require.NoError(t, err)
assert.Len(t, pr.Streams, 1)
Expand Down

0 comments on commit 7e16199

Please sign in to comment.