Skip to content

Commit

Permalink
RE-1902 Use single, large runner for core tests (#10604)
Browse files Browse the repository at this point in the history
* Test out single shard, large runner tests

* Test giga runners

* Remove dead code from split-tests
  • Loading branch information
HenryNguyen5 authored Sep 20, 2023
1 parent 2584384 commit 347541a
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 233 deletions.
51 changes: 0 additions & 51 deletions .github/actions/split-tests/src/handlers/golang.mts

This file was deleted.

83 changes: 10 additions & 73 deletions .github/actions/split-tests/src/index.mts
Original file line number Diff line number Diff line change
@@ -1,24 +1,16 @@
import {$, cd, glob, fs} from "zx";
import { $, cd, glob, fs } from "zx";
import path from "node:path";
import {summary, setOutput} from "@actions/core";
import {
GolangConfig,
SolidityConfig,
GoSplits,
Tests,
SoliditySplit,
TestsBySplit,
} from "./types.mjs";
import {sieveSlowTests} from "./sieve.mjs";
import {simpleSplit} from "./splitter.mjs";
import { getPackageList, GetGoPackagesReturn } from "../src/handlers/golang.mjs";
import { setOutput } from "@actions/core";
import { SolidityConfig, SoliditySplit } from "./types.mjs";
import { sieveSlowTests } from "./sieve.mjs";
import { simpleSplit } from "./splitter.mjs";

/**
* Get a JSON formatted config file
*
* @param path The path to the config relative to the git root
*/
function getConfigFrom(path?: string): GolangConfig | SolidityConfig {
function getConfigFrom(path?: string): SolidityConfig {
if (!path) {
throw Error("No config path given, specify a path via $CONFIG");
}
Expand All @@ -37,33 +29,25 @@ async function main() {
await runAtGitRoot();
const configPath = process.env.CONFIG;
const config = getConfigFrom(configPath);
if (config.type === "golang") {
await handleGolang(config);
} else if (config.type === "solidity") {
if (config.type === "solidity") {
await handleSolidity(config);
} else {
throw Error(`Invalid config given`);
}
}
main();

async function handleGolang(config: GolangConfig) {
const p: GetGoPackagesReturn = getPackageList(config)
setOutput("splits", p.serializedSplits);
createSummary(p.packages, p.testsBySplit, p.splits);
}

async function handleSolidity(config: SolidityConfig) {
const {basePath, splits: configBySplit} = config;
const { basePath, splits: configBySplit } = config;
const splits = await Promise.all(
configBySplit.map(
async ({dir, numOfSplits, slowTests: slowTestMatchers}) => {
async ({ dir, numOfSplits, slowTests: slowTestMatchers }) => {
const globPath = path.join(basePath, dir, "/**/*.test.ts");
const rawTests = await glob(globPath);
const pathMappedTests = rawTests.map((r) =>
r.replace("contracts/", "")
);
const {filteredTests, slowTests} = sieveSlowTests(
const { filteredTests, slowTests } = sieveSlowTests(
pathMappedTests,
slowTestMatchers
);
Expand All @@ -84,53 +68,6 @@ async function handleSolidity(config: SolidityConfig) {
setOutput("splits", serializedSplits);
}

function createSummary(
packages: Tests,
packagesBySplit: TestsBySplit,
splits: GoSplits
) {
if (!process.env.CI) {
return;
}
const numberOfPackages = packages.length;
const numberOfSplits = packagesBySplit.length;
const postProcessedNumberOfPackages = packagesBySplit.flat().length;

summary
.addHeading("Spliting Summary")
.addHeading(
`Number of packages from "go list ./...": ${numberOfPackages}`,
3
)
.addHeading(
`Number of packages placed into splits: ${postProcessedNumberOfPackages}`,
3
)
.addHeading(`Number of splits created: ${numberOfSplits}`, 3)
.addBreak()
.addTable([
[
{data: "Split Number", header: true},
{data: "Packages Tested", header: true},
],
...splits.map((p) => {
const mappedPackages = p.pkgs
.split(" ")
.map(
(packageName) =>
`<li> ${packageName.replace(
"github.com/smartcontractkit/",
""
)} </li>`
)
.join("\n");

return [p.id, mappedPackages];
}),
])
.write();
}

async function runAtGitRoot() {
const gitRoot = await $`git rev-parse --show-toplevel`;
cd(gitRoot.stdout.trimEnd());
Expand Down
37 changes: 0 additions & 37 deletions .github/actions/split-tests/src/types.mts
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,6 @@ export interface Split {
id: string;
}

export interface GoSplit extends Split {
/**
* A space delimited list of packages to run within this split
*/
pkgs: string;
}

export interface SoliditySplit extends Split {
/**
* A string that contains a whitespace delimited list of tests to run
Expand All @@ -47,19 +40,6 @@ export interface SoliditySplit extends Split {
coverageTests: string;
}

export type GoSplits = GoSplit[];

/**
* Configuration file for golang tests
*/
export interface GolangConfig {
type: "golang";
/**
* The number of splits to run tests across
*/
numOfSplits: number;
}

/**
* Configuration file for solidity tests
*/
Expand Down Expand Up @@ -93,20 +73,3 @@ export interface SolidityConfig {
slowTests?: string[];
}[];
}

export interface GoPackageData {
/**
* The package path
*/
ImportPath: string;
/**
* The list of go files asociated with the package
*/
TestGoFiles: string[] | undefined;
/**
* The list of go files not associated with a specific package
* Things like integration tests
*/
XTestGoFiles: string[] | undefined;
// there are many other variables in the data but they are not needed yet
}
73 changes: 5 additions & 68 deletions .github/workflows/ci-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,50 +54,13 @@ jobs:
this-job-name: lint
continue-on-error: true

split-packages:
name: Split Go Tests
if: ${{ !contains(join(github.event.pull_request.labels.*.name, ' '), 'skip-smoke-tests') }}
runs-on: ubuntu-latest
outputs:
splits: ${{ steps.split.outputs.splits }}
steps:
- name: Check for Skip Tests Label
if: contains(join(github.event.pull_request.labels.*.name, ' '), 'skip-smoke-tests')
run: |
echo "## \`skip-smoke-tests\` label is active, skipping E2E smoke tests" >>$GITHUB_STEP_SUMMARY
exit 0
- name: Checkout the repo
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
- name: Setup Go
uses: ./.github/actions/setup-go
with:
only-modules: "true"
- name: Touching core/web/assets/index.html
run: mkdir -p core/web/assets && touch core/web/assets/index.html
- name: Generate splits
id: split
uses: ./.github/actions/split-tests
with:
config: ./ci.json
- name: Collect Metrics
if: always()
id: collect-gha-metrics
uses: smartcontractkit/push-gha-metrics-action@d2c2b7bdc9012651230b2608a1bcb0c48538b6ec
with:
basic-auth: ${{ secrets.GRAFANA_CLOUD_BASIC_AUTH }}
hostname: ${{ secrets.GRAFANA_CLOUD_HOST }}
this-job-name: Split Go Tests
continue-on-error: true

core:
needs: [split-packages]
strategy:
fail-fast: false
matrix:
cmd: ["go_core_tests", "go_core_race_tests"]
split: ${{ fromJson(needs.split-packages.outputs.splits) }}
name: Core Tests (${{ matrix.cmd }}) ${{ matrix.split.id }}
runs-on: ubuntu-latest
name: Core Tests (${{ matrix.cmd }})
runs-on: ubuntu20.04-64cores-256GB
env:
CL_DATABASE_URL: postgresql://postgres:postgres@localhost:5432/chainlink_test?sslmode=disable
steps:
Expand Down Expand Up @@ -135,7 +98,7 @@ jobs:
env:
OUTPUT_FILE: ./output.txt
USE_TEE: false
run: ./tools/bin/${{ matrix.cmd }} "${{ matrix.split.pkgs }}"
run: ./tools/bin/${{ matrix.cmd }} ./...
- name: Print Filtered Test Results
if: failure()
uses: smartcontractkit/chainlink-github-actions/go/go-test-results-parsing@eccde1970eca69f079d3efb3409938a72ade8497 # v2.2.13
Expand All @@ -146,7 +109,7 @@ jobs:
if: always()
uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0
with:
name: ${{ matrix.cmd }}_${{ matrix.split.idx }}_logs
name: ${{ matrix.cmd }}_logs
path: |
./output.txt
./output-short.txt
Expand All @@ -156,33 +119,6 @@ jobs:
if: always()
run: docker compose logs postgres
working-directory: ./.github/actions/setup-postgres
- name: Collect Metrics
if: always()
id: collect-gha-metrics
uses: smartcontractkit/push-gha-metrics-action@d2c2b7bdc9012651230b2608a1bcb0c48538b6ec
with:
basic-auth: ${{ secrets.GRAFANA_CLOUD_BASIC_AUTH }}
hostname: ${{ secrets.GRAFANA_CLOUD_HOST }}
this-job-name: Core Tests (${{ matrix.cmd }}) ${{ matrix.split.id }}
test-results-file: '{"testType":"go","filePath":"./output.txt"}'
continue-on-error: true

# Satisfy required check for core tests
# while still allowing for adjustable splitting
core-complete:
needs: [core]
name: Core Tests (${{ matrix.cmd }})
runs-on: ubuntu-latest
if: always()
strategy:
fail-fast: false
matrix:
cmd: ["go_core_tests", "go_core_race_tests"]
steps:
- run: echo "${{ matrix.cmd }} have finished"
- name: Check test results
if: needs.core.result != 'success'
run: exit 1
- name: Notify Slack
if: ${{ failure() && matrix.cmd == 'go_core_race_tests' && github.event.schedule != '' }}
uses: slackapi/slack-github-action@e28cf165c92ffef168d23c5c9000cffc8a25e117 # v1.24.0
Expand All @@ -199,6 +135,7 @@ jobs:
basic-auth: ${{ secrets.GRAFANA_CLOUD_BASIC_AUTH }}
hostname: ${{ secrets.GRAFANA_CLOUD_HOST }}
this-job-name: Core Tests (${{ matrix.cmd }})
test-results-file: '{"testType":"go","filePath":"./output.txt"}'
continue-on-error: true

detect-flakey-tests:
Expand Down
4 changes: 0 additions & 4 deletions ci.json

This file was deleted.

0 comments on commit 347541a

Please sign in to comment.