Skip to content

Feat: skip building actors if only tests changed#33

Open
kazadoiyul wants to merge 2 commits intopretify-build-logsfrom
feat/skip-build
Open

Feat: skip building actors if only tests changed#33
kazadoiyul wants to merge 2 commits intopretify-build-logsfrom
feat/skip-build

Conversation

@kazadoiyul
Copy link
Contributor

Closes #1

@kazadoiyul kazadoiyul changed the base branch from master to pretify-build-logs October 22, 2025 08:37
@kazadoiyul kazadoiyul marked this pull request as ready for review October 22, 2025 08:38
@kazadoiyul kazadoiyul requested a review from oklinov October 22, 2025 08:38
Copy link
Collaborator

@oklinov oklinov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry for the delay 🙁

}
}

async getDefaultBuilt() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this isn't needed...you can extend getDefaultVersionAndTag to return buildId:

    const defaultBuildId = actorInfo.taggedBuilds![defaultBuildTag].buildId!;

setCwd,
} from './utils.js';
import { runBuilds } from './build.js';
import {getAllDefaultBuilds, runBuilds} from './build.js';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import {getAllDefaultBuilds, runBuilds} from './build.js';
import { getAllDefaultBuilds, runBuilds } from './build.js';

return IGNORED_TOP_LEVEL_FILES.some((ignoredFile) => sanitizedLowercaseFilePath.startsWith(ignoredFile));
};

const isIgnoredTestFile = (lowercaseFilePath: string) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should check if the lowercaseFilePath is a platform test, you can do it like this:

        return lowercaseFilePath.match(/^(code\/)?test\/platform\//);

I'd also rename it to isPlatformTestFile

return;
}

// add a build entry even if no build was triggered to run the tests on all actors
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will run always the tests for the actors that we're not building, no? My idea was to run them only if there is a changed in platform tests (in test/platfrom).

What I would do is to have getChangedActors return actorsToTest if there is such change. So, if we detect that there is a change in platform tests, we put all the actors that are not being built to actorsToTest.

I prepared some unit tests that hopefully explain the logic:

    test('only core tests changed', async () => {
        const FILES = [
            'test/platform/core/core.test.ts',
        ];

        const { actorsChanged, actorsToTest, codeChanged } = await getChangedActors({ actorConfigs: ACTOR_CONFIGS, isLatest: false, filepathsChanged: FILES });

        expect(actorsChanged).toEqual([]);
        expect(actorsToTest).toEqual(ACTOR_CONFIGS);
        expect(codeChanged).toBe(false);
    });

    test('core tests and src (excluding standalone actors) changed', async () => {
        const FILES = [
            'src/main.ts',
            'test/platform/core/core.test.ts',
        ];

        const { actorsChanged, actorsToTest, codeChanged } = await getChangedActors({ actorConfigs: ACTOR_CONFIGS, isLatest: false, filepathsChanged: FILES });

        expect(actorsChanged).toEqual(ACTOR_CONFIGS.filter((actor) => actor.isStandalone));
        expect(actorsToTest).toEqual(ACTOR_CONFIGS.filter((actor) => !actor.isStandalone));
        expect(codeChanged).toBe(false);
    });

    test('core tests and one input_schema changed', async () => {
        const FILES = [
            'test/platform/core/core.test.ts',
            'actors/lukaskrivka_testing-github-integration-1/.actor/INPUT_SCHEMA.json'
        ];

        const { actorsChanged, actorsToTest, codeChanged } = await getChangedActors({ actorConfigs: ACTOR_CONFIGS, isLatest: false, filepathsChanged: FILES });

        expect(actorsChanged).toEqual([ACTOR_CONFIGS[0]]);
        expect(actorsToTest).toEqual(ACTOR_CONFIGS.slice(1));
        expect(codeChanged).toBe(false);
    });

let me know if something's not clear

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Skip building of actors if only tests changed

2 participants