Skip to content

Commit

Permalink
Merge branch 'master' into UlyanaAndrukhiv/6138-synchronization-impov…
Browse files Browse the repository at this point in the history
…ements
  • Loading branch information
UlyanaAndrukhiv authored Jun 26, 2024
2 parents 830a8d9 + b0b3ee9 commit 38ece02
Show file tree
Hide file tree
Showing 22 changed files with 875 additions and 192 deletions.
23 changes: 18 additions & 5 deletions .github/workflows/actions/test-monitor-process-results/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ name: Test Monitor - Process Results
description: Custom action that's used in multiple Flaky Test Monitor jobs to process test results and upload them to BigQuery

inputs:
gcp_sa_key:
description: 'The GCP service account key for uploading to BigQuery'
service_account:
description: 'The GCP Service Account'
required: true
workload_identity_provider:
description: 'The GCP Workload Identity Provider'
required: true

runs:
Expand All @@ -14,20 +17,30 @@ runs:
id: commit_date
run: echo "::set-output name=date::$(git show --no-patch --no-notes --pretty='%cI' $COMMIT_SHA)"
shell: bash

- name: Get job run date
id: job_run_date
run: echo "::set-output name=date::$(TZ=":UTC" date -Iseconds)"
shell: bash

- name: Process test results
run: cat test-output | go run tools/test_monitor/level1/process_summary1_results.go
env:
JOB_STARTED: ${{ steps.job_run_date.outputs.date }}
COMMIT_DATE: ${{ steps.commit_date.outputs.date }}
shell: bash
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v0

- name: Google auth
id: auth
uses: google-github-actions/auth@v2
with:
service_account_key: ${{ inputs.gcp_sa_key }}
service_account: ${{ inputs.service_account }}
token_format: 'access_token'
workload_identity_provider: ${{ inputs.workload_identity_provider }}

- name: 'Set up Cloud SDK'
uses: 'google-github-actions/setup-gcloud@v2'

- name: Upload results to BigQuery (skipped tests)
uses: nick-fields/retry@v2
with:
Expand Down
15 changes: 11 additions & 4 deletions .github/workflows/flaky-test-monitor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ on:
push:
paths:
- '.github/workflows/flaky-test-monitor.yml'
permissions:
id-token: write
contents: read

env:
BIGQUERY_DATASET: production_src_flow_test_metrics
BIGQUERY_DATASET: dev_src_flow_test_metrics
BIGQUERY_TABLE: skipped_tests
BIGQUERY_TABLE2: test_results
GO_VERSION: "1.22"
Expand Down Expand Up @@ -73,7 +76,8 @@ jobs:
TEST_CATEGORY: unit
uses: ./.github/workflows/actions/test-monitor-process-results
with:
gcp_sa_key: ${{ secrets.GCP_SA_KEY }}
service_account: ${{ secrets.FLAKY_TEST_SERVICE_ACCOUNT }}
workload_identity_provider: ${{ secrets.FLAKY_TEST_WORKLOAD_IDENTITY_PROVIDER }}

unit-test-modules:
name: Unit Tests (Modules)
Expand Down Expand Up @@ -115,7 +119,8 @@ jobs:
TEST_CATEGORY: ${{ matrix.test_category }}
uses: ./.github/workflows/actions/test-monitor-process-results
with:
gcp_sa_key: ${{ secrets.GCP_SA_KEY }}
service_account: ${{ secrets.FLAKY_TEST_SERVICE_ACCOUNT }}
workload_identity_provider: ${{ secrets.FLAKY_TEST_WORKLOAD_IDENTITY_PROVIDER }}

integration-test:
name: Integration Tests
Expand Down Expand Up @@ -175,4 +180,6 @@ jobs:
TEST_CATEGORY: ${{ matrix.test_category }}
uses: ./.github/workflows/actions/test-monitor-process-results
with:
gcp_sa_key: ${{ secrets.GCP_SA_KEY }}
service_account: ${{ secrets.FLAKY_TEST_SERVICE_ACCOUNT }}
workload_identity_provider: ${{ secrets.FLAKY_TEST_WORKLOAD_IDENTITY_PROVIDER }}

10 changes: 10 additions & 0 deletions cmd/util/ledger/migrations/cadence.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,16 @@ func NewCadence1ValueMigrations(
programs := make(map[common.Location]*interpreter.Program, 1000)

migs = []NamedMigration{
{
Name: "cleanup-contracts",
Migrate: NewAccountBasedMigration(
log,
opts.NWorker,
[]AccountBasedMigration{
NewContractCleanupMigration(rwf),
},
),
},
{
Name: "check-contracts",
Migrate: NewContractCheckingMigration(
Expand Down
69 changes: 69 additions & 0 deletions cmd/util/ledger/migrations/cadence_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package migrations

import (
"testing"

"github.com/onflow/cadence/runtime/common"
"github.com/onflow/cadence/runtime/interpreter"
"github.com/rs/zerolog"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/onflow/flow-go/cmd/util/ledger/util/registers"
"github.com/onflow/flow-go/fvm/environment"
"github.com/onflow/flow-go/model/flow"
)

func TestMigrateCadence1EmptyContract(t *testing.T) {

t.Parallel()

const chainID = flow.Testnet

address, err := common.HexToAddress("0x4184b8bdf78db9eb")
require.NoError(t, err)

const contractName = "FungibleToken"

registersByAccount := registers.NewByAccount()

err = registersByAccount.Set(
string(address[:]),
flow.ContractKey(contractName),
// some whitespace for testing purposes
[]byte(" \t \n "),
)
require.NoError(t, err)

encodedContractNames, err := environment.EncodeContractNames([]string{contractName})
require.NoError(t, err)

err = registersByAccount.Set(
string(address[:]),
flow.ContractNamesKey,
encodedContractNames,
)
require.NoError(t, err)

programs := map[common.Location]*interpreter.Program{}

rwf := &testReportWriterFactory{}

// Run contract checking migration

log := zerolog.Nop()
checkingMigration := NewContractCheckingMigration(log, rwf, chainID, false, programs)

err = checkingMigration(registersByAccount)
require.NoError(t, err)

reporter := rwf.reportWriters[contractCheckingReporterName]
assert.Empty(t, reporter.entries)

// Initialize metrics collecting migration (used to run into unexpected error)

metricsCollectingMigration := NewMetricsCollectingMigration(log, chainID, rwf, programs)

err = metricsCollectingMigration.InitMigration(log, registersByAccount, 1)
require.NoError(t, err)
}
5 changes: 5 additions & 0 deletions cmd/util/ledger/migrations/contract_checking_migration.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package migrations

import (
"bytes"
"encoding/json"
"fmt"
"sort"
Expand Down Expand Up @@ -78,6 +79,10 @@ func NewContractCheckingMigration(
return err
}

if len(bytes.TrimSpace(code)) == 0 {
continue
}

address := common.Address([]byte(owner))
location := common.AddressLocation{
Address: address,
Expand Down
Loading

0 comments on commit 38ece02

Please sign in to comment.