Skip to content

Commit

Permalink
add test by file feature
Browse files Browse the repository at this point in the history
  • Loading branch information
Laucans committed Apr 26, 2023
1 parent 34c17eb commit 2c69bb0
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 11 deletions.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,14 @@ The name of the Flextesa sandbox to use. A sandbox will only be created if this

The name of a specific task to run. This input is mainly used for testing purposes.

### `tests`
### `test_plugin`

When set to jest, all tests in the `tests` directory will be run using the Jest plugin. This option makes use of the `jest` plugin so please make sure to install it.

### `test_files`

When set to jest, all tests in the `tests` directory will be run using same plugin than the compile one.

When set to true, all tests in the `tests` directory will be run using the Jest plugin. This option makes use of the `jest` plugin so please make sure to install it.

## Example usage

Expand Down
9 changes: 6 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ inputs:
required: false
default: 'ligo'
deploy_contracts:
description: 'A comma seperated list of contracts to deploy to a specific environment. The Taquito plugin needs to be installed'
description: 'A comma separated list of contracts to deploy to a specific environment. The Taquito plugin needs to be installed'
required: false
environment:
description: 'The environment to execute commands on. The default is "development"'
required: false
default: 'development'
plugins:
description: 'A comma seperated list of plugins to install'
description: 'A comma separated list of plugins to install'
required: false
project_directory:
description: 'The name of the project to create'
Expand All @@ -34,10 +34,12 @@ inputs:
description: If set, taqueria will run tests with using the specified plugin. Ensure that the specified plugin is installed. These test will always be run after all other jobs.
required: false
ligo_libraries:
description: 'A comma seperated list. If compile plugin is "ligo" this parameter can be used to install ligo libraries. Example ligo/fa'
description: 'A comma separated list. If compile plugin is "ligo" this parameter can be used to install ligo libraries. Example ligo/fa'
required: false
taq_ligo_image:
description: 'If compile plugin is "ligo" this parameter can be used to override the ligo image used.'
test_files:
description: 'A comma separated list. Represent files to run test on them'

runs:
using: 'docker'
Expand All @@ -54,3 +56,4 @@ runs:
- ${{ inputs.test_plugin }}
- ${{ inputs.ligo_libraries }}
- ${{ inputs.taq_ligo_image }}
- ${{ inputs.test_files }}
30 changes: 24 additions & 6 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
## Because of the docker-in-docker setup for the action we need to set 'localhost' to the host docker IP
echo "172.17.0.1 localhost" >/etc/hosts

exit_code=0

if [ -z "$INPUT_PROJECT_DIRECTORY" ]; then
export PROJECT_DIR=$RUNNER_WORKSPACE/${GITHUB_REPOSITORY#*/}
else
Expand All @@ -14,8 +16,6 @@ if [ "$INPUT_TASK" == "init" ]; then
taq init
fi

echo $TAQ_LIGO_IMAGE

if [ -n "$INPUT_TAQ_LIGO_IMAGE" ]; then
echo "overriding Ligo version with $INPUT_TAQ_LIGO_IMAGE"
export TAQ_LIGO_IMAGE=$INPUT_TAQ_LIGO_IMAGE
Expand All @@ -33,7 +33,7 @@ if [ -n "$INPUT_LIGO_LIBRARIES" ]; then
# for each ligo lib in the comma separated INPUT_LIGO_LIBRARIES install the library
for ligo_lib in $(echo $INPUT_LIGO_LIBRARIES | tr "," "\n"); do
echo "Installing ligo lib $ligo_lib"
docker run --rm -v "$PWD":"$PWD" -w "$PWD" $TAQ_LIGO_IMAGE install ${ligo_lib}
taq ligo --command "install @ligo/fa"
done
fi

Expand All @@ -45,20 +45,35 @@ if [ -n "$INPUT_CONTRACTS" ]; then
done
fi

if [ -n "$INPUT_COMPILE_CONTRACTS" ]; then
if [ -n "$INPUT_COMPILE_CONTRACTS" ] && [ -n "$INPUT_COMPILE_PLUGIN" ]; then
# for each contract in the comma separated INPUT_CONTRACTS register the contract
for contract in $(echo $INPUT_COMPILE_CONTRACTS | tr "," "\n"); do
echo "Compiling $contract"
taq compile "$contract" --plugin "$INPUT_COMPILE_PLUGIN"
result=$?
exit_code=$(($exit_code + $result))
done
chmod -R 777 ./artifacts
fi

if [ -n "$INPUT_TEST_FILES" ] && [ -n "$INPUT_COMPILE_PLUGIN" ]; then
for file in $(echo $INPUT_TEST_FILES | tr "," "\n"); do
echo "Testing $file"
taq test $file --plugin "$INPUT_COMPILE_PLUGIN" >results.log
cat results.log
if grep -q "Some tests failed" results.log; then
exit_code=$(($exit_code + 1))
fi
done
fi

if [ -n "$INPUT_DEPLOY_CONTRACTS" ]; then
# for each contract in the comma separated INPUT_CONTRACTS register the contract
for contract in $(echo "$INPUT_DEPLOY_CONTRACTS" | tr "," "\n"); do
echo "Deploying $contract"
taq deploy "$contract" --env "$INPUT_ENVIRONMENT"
result=$?
exit_code=$(($exit_code + $result))
done
fi

Expand All @@ -75,7 +90,10 @@ if [ -n "$INPUT_TEST_PLUGIN" ]; then
chmod -R 777 ./.taq
echo "Running tests using plugin $INPUT_TEST_PLUGIN"
taq test --plugin "$INPUT_TEST_PLUGIN"
exit_code=$?
result=$?
exit_code=$(($exit_code + $result))
chmod -R 755 ./.taq
exit $exit_code
fi

echo "Exit code : $exit_code"
exit $exit_code

0 comments on commit 2c69bb0

Please sign in to comment.