Github action for smart contracts automated testing with Hydra.
This action will compile your contracts and execute hydra test
on your project's root directory.
Run the following commands to initialize your repo, this github action expects the generated structure.
mkdir myproject && cd myproject
eosio init -project myproject
mv myproject contracts
hydra init
The contracts are automatically compiled using cmake v3.10
, eosio.cdt v1.7.0
on ubuntu v18.04
Define a workflow in .github/workflows/my-workflow.yml
(or add a job if you already have defined workflows).
💡 Read more about Configuring a workflow.
on:
pull_request:
push:
branches:
- master
tags:
- "**"
name: "Smart Contracts Tests"
jobs:
test:
name: test
runs-on: ubuntu-latest
steps:
- name: "Checkout"
uses: actions/checkout@master
- name: "Run hydra test"
uses: docker://blockmatic/eosio-hydra-action:latest
env:
HYDRA_AUTH: ${{ secrets.HYDRA_AUTH }}
Running the interactive hydra login
command is not an option on most CI servers. Instead, we recommend running hydra login locally and passing the resulting JSON authentication payload as a secure environment variable to the CI server.
The JSON authentication payload can be found in the ~/.hydra/auth.json
file after login. It can then be passed as the HYDRA_AUTH
environment variable to the CI server. The authentication info automatically renews expired authentication tokens as it includes a refresh token, therefore this setup only needs to be done once.
💡 Read more about Creating and storing encrypted secrets.
As Docker images are automatically built and pushed on a merge to master
or when a new tag is created in this repository, the recommended way to use this GitHub action is to reference the pre-built Docker image directly, as seen above.
💡 The Docker image can also be executed directly by running
$ docker run --interactive --rm --tty --workdir=/app --volume ${PWD}:/app -e HYDRA_AUTH=$(cat ~/.hydra/auth.json) blockmatic/eosio-hydra-action:latest
For more information, see the Docker Docs: Docker run reference.
Instead of using the latest pre-built Docker image, you can also specify a Docker image tag (which corresponds to the tags released on GitHub):
name: Hydra Tests
on:
pull_request:
push:
branches:
- master
tags:
- "**"
jobs:
test:
name: test
runs-on: ubuntu-latest
steps:
- name: "Checkout"
uses: actions/checkout@master
- name: "Run hydra test"
- uses: docker://blockmatic/eosio-hydra-action:latest
+ uses: docker://blockmatic/eosio-hydra-action:1.2.3
env:
HYDRA_AUTH: ${{ secrets.HYDRA_AUTH }}
Read the contributing guidelines for details.
Blockmatic is building a robust ecosystem of people and tools for the development of blockchain applications.