actions / actions/toolkit

Add a tool for integration testing of a Github Action locally

Open
#1,306 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
TypeScript
Stars
5.9k
Forks
1.8k
PR merge metrics
No merged PRs in 30d

Description

Describe the enhancement
To test the correctness of an Action developers need permanently push their changes to GitHub that leads to:

  • creating extra load on workers
  • bloating repos
  • having long feedback loop for developers
  • the only possibility to write tests is creating special test workflows that is not convenient and doesn't allow to debug actions

As a author of many actions I faced this problem and created a library that allows:

  • running actions locally (Windows, MacOS, Linux) or on any CI (including GitHub Actions itself)
  • run JS (in the same or child process) and Docker actions
  • passing test values as inputs, env vars, etc using nice TypeScript API (full support of Actions features)
  • examine results of the Action run: outputs, exit code, issued commands in a manner familiar to any JS developer with their favorite testing tool

I suggest adding the library to the list of the tools. I believe that popularization of integration testing for GitHub Actions can improve the quality of Actions on the Marketplace and attract more developers to the Actions ecosystem.

Code Snippet
Test example:

import {RunOptions, RunTarget} from 'github-action-ts-run-api';

// RunTarget.preJsScript() and RunTarget.postJsScript() are also available
const target = RunTarget.mainJsScript('action.yml');
const options = RunOptions.create()
.setInputs({in1: 'abc'})
    .setEnv({ENV2: 'def'})
    .setState({my_state: 'ghi'});

const result = await target.run(options);

assert(result.durationMs >= 1000);
assert(result.commands.outputs === {out1: 'abc', out2: 'def'});
assert(result.commands.exportedVars === {v3: 'ghi'});
assert(result.exitCode === 1);
assert(result.warnings.length === 0);

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the proposed github-action-ts-run-api library and the action.yml entry point shown in the example. Confirm where the toolkit's list of tools is maintained and whether this project accepts a new integration-testing tool; done would be a reviewed addition with the library's purpose and usage documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
github-actions, typescript
Domain
ci-cd, testing-qa, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.