Run tests without commit - Buildbot try

Hi,

I am wondering if there is already a way to run a test suite inside a workflow without pushing a commit.

Here is what I got so far… is all open source https://github.com/chevah/brink/pull/120 , but is based on the legacy buildbot code designed to run on AIX 5.3, HPUX and Solaris 10 on Sparc.

asciicast

I am using buildbot try (https://docs.buildbot.net/current/manual/cmdline.html#try) command to help with TDD for multi-OS code.

Most of the time my usage is as follows.
I develop on my local OS (ex Linux). I make sure all the tests pass.
I then push a commit.
I find out that some tests are failing on Windows or MacOS.
I then start using buildbot try to just re-run the selected tests for a patch without a commit
The tests are run on private hosted VM which are not reset at the end of the test run.
So is like a remote command execution.


I did a proof of concept tool for GitHub actions using the workflow_dispatch event which has a diff as input.
I create a local diff for uncommitted changed, encode it in base64 and then send it to the workflow.

Then the workflow has the required rules for decoding and applying the diff.

For now is a big hack, as it looks like the current API is not designed for such an usage.
When I trigger the workflow_dispatch via the REST API I don’t get the run ID as part of the response.


What do you think?

@adiroiban,

When I trigger the workflow_dispatch via the REST API I don’t get the run ID as part of the response.

Yeah, currently the “Create a workflow dispatch event” API only returns a status code (e.g. 204 No Content) in the Response. Just like the “Create a repository dispatch event” API (for repository_dispatch).

If you want to view the detailed information of the triggered workflow run, you can output the github context in the workflow run.

- name: Dump GitHub context
  env:
    GITHUB_CONTEXT: ${{ toJson(github) }}
  run: echo "$GITHUB_CONTEXT"

Of course, if your projects really need the feature that the “Create a workflow dispatch event” API can return the id of the triggered workflow run in the Response, I recommend that you can directly report a feature request here. That will allow you to directly interact with the appropriate engineering team, and make it more convenient for the engineering team to collect and categorize your suggestions.

Thanks for your response.
I have already made a feature request for the run ID.
For now, constantly checking for new jobs works as we don’t have multiple person running the event at the same time for the same branch.


I prefer this way of dumping the context, as I get a nicely formatted json.

    - name: Show action context
      run: |
        echo << EOF
        ${{ toJSON(github) }}
        EOF

Do you know why using following conditions doesn’t work

  linux_unicode_path:
    runs-on: ubuntu-20.04
    if: github.event.inputs.job == '' || github.event.inputs.job == github.job

But if I use something like this works?

  linux_unicode_path:
    runs-on: ubuntu-20.04
    if: github.event.inputs.job == '' || github.event.inputs.job == 'linux_unicode_path'

I have checked the Github context value, and github.event.inputs.job and github.job are set to the same value.

Thanks

@adiroiban,

Do you know why using following conditions doesn’t work
linux_unicode_path:
runs-on: ubuntu-20.04
if: github.event.inputs.job == ‘’ || github.event.inputs.job == github.job

There are few points you may need to understand:

  1. The id of current job won’t be assigned to the property ‘github.job’ until the job starts up.
    When you use the expression ‘github.job’ on the job level if conditional, it will always return ‘null’ since the current job has not started up.
    So, you can only use the expression ‘github.job’ in the steps (include the step level if conditional) after the current job starts up.

  2. For the expression ‘github.event.inputs.job’, if the current workflow run is not triggered on the ‘workflow_dispatch’ event, the github context will not contain the object ‘github.event.inputs’.
    So, when the workflow is triggered on other events, the expression ‘github.event.inputs.job’ or ‘github.event.inputs’ may always return ‘null’, and the if statement (github.event.inputs.job == ‘’) will always return ‘true’.

To make sure the job ‘linux_unicode_path’ in your workflow only run when the current workflow run is triggered on the ‘workflow_dispatch’ event, and can meet the conditional (github.event.inputs.job == ‘’) or (github.event.inputs.job == linux_unicode_path), you can change the job level if conditional to like below:

linux_unicode_path:
    runs-on: ubuntu-20.04
    if: ${{ github.event_name == 'workflow_dispatch' && (github.event.inputs.job == '' || github.event.inputs.job == 'linux_unicode_path') }}