Github Actions implementation in project with test machine

Viewed 221

Current architecture of our project is pretty simple:

Multiple Github repos merge in Master and deploy to Server.

But we want to add Testing to it. And currently I'm investigating Github Actions possibility.

Is it possible to make this setup:

  1. Code getting merged to "Develop" branch and trigger Github Action
  2. Github Action push code to Test server and run all Unit Tests
  3. return test result, maybe as Email or something.
  4. If tests are successful Develop branch getting merged to Master.

Is it possible to setup all of this just with Github Action or we will need to add Jenkins or Travis??

Thank you for your time.

2 Answers

GitHub action is limited to GitHub servers.

If your Test server is accessible from internet, you can use a deployment GitHub action.

But it is more common to have use a GitHub server, and set it up (thrugh a Docker image, or through actions like setup-java) to represent your execution environment (test or otherwise).

See for instance "Continuous deployment using Docker, GitHub Actions, and Web-hooks" by Arthur Effting (CTO @ accuras)

Create two new YAML configuration files in the root of your project in the /.github/workflows folder.

  • The first file will be used for the master branch and will run some tests to make sure every push is OK.
  • The second one will be applied to release branches only and will not only test the new version but also create a docker image for it and trigger a redeploy.
name: Master - Testing

on:
  push:
    branches:
      - 'master'

jobs:

  artifact:

    name: Test master branch - GitHub Packages
    runs-on: ubuntu-18.04

    steps:
      - uses: actions/checkout@v1
      - name: Set up JDK 11
        uses: actions/setup-java@v1
        with:
          java-version: 11.0.4
      - name: Maven Package
        run: mvn -B clean package -DskipTests
      - name: Maven Verify
        run: mvn -B clean verify

https://miro.medium.com/max/1400/1*l0nTe86ypMoU9rvg9_UEgw.png

I am working on a workflow where the code is pushed to the test server and tested by:

  • building a docker image and pushing it to dockerhub
  • using appleboy/ssh-action to pull the docker image and run the tests in the test server.

I created the workflow for a dummy test case at https://github.com/bmichele/remote-unit-tests, so that it can be modified for real use cases. If the test fails, the action will fail and you will be notified.

Note that with the current configuration the workflow runs at every push, you have to modify it for your needs. Also, it uses a proxy to access the test server. If you don't need a proxy, you can drop the proxy_host, proxy_username and proxy_key fields from the yaml file).

Related