Initialize test folder as a Git repository #486
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Follow the README instructions to use this action in your repository. | |
name: Test | |
on: [push, pull_request] | |
env: | |
IMAGE: axelop/dart_package_analyzer:test | |
DOCKERFILE: Dockerfile-parent | |
jobs: | |
test-outputs: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Build container | |
run: sudo docker build -f $DOCKERFILE -t $IMAGE . | |
- name: Run tests | |
id: steptest | |
run: | | |
sudo docker run -d -t --name test $IMAGE | |
sudo docker cp ${GITHUB_WORKSPACE}/test/. test:/test | |
sudo docker cp ${GITHUB_EVENT_PATH} test:/event.json | |
sudo docker exec -e GITHUB_RUN_NUMBER=$GITHUB_RUN_NUMBER -e GITHUB_EVENT_PATH=/event.json -e GITHUB_WORKSPACE=/test -e GITHUB_SHA=$GITHUB_SHA -e GITHUB_REPOSITORY=$GITHUB_REPOSITORY -e INPUT_MINANNOTATIONLEVEL=info -e INPUT_GITHUBTOKEN=${{ secrets.GITHUB_TOKEN }} test /bin/bash -c "/dart_package_analyzer" | |
- name: Test outputs | |
env: | |
JSON_OUTPUT: ${{ steps.steptest.outputs.json_output }} | |
TOTAL: ${{ steps.steptest.outputs.total }} | |
TOTAL_MAX: ${{ steps.steptest.outputs.total_max }} | |
CONVENTIONS: ${{ steps.steptest.outputs.conventions }} | |
CONVENTIONS_MAX: ${{ steps.steptest.outputs.conventions_max }} | |
DOCUMENTATION: ${{ steps.steptest.outputs.documentation }} | |
DOCUMENTATION_MAX: ${{ steps.steptest.outputs.documentation_max }} | |
PLATFORMS: ${{ steps.steptest.outputs.platforms }} | |
PLATFORMS_MAX: ${{ steps.steptest.outputs.platforms_max }} | |
ANALYSIS: ${{ steps.steptest.outputs.analysis }} | |
ANALYSIS_MAX: ${{ steps.steptest.outputs.analysis_max }} | |
DEPENDENCIES: ${{ steps.steptest.outputs.dependencies }} | |
DEPENDENCIES_MAX: ${{ steps.steptest.outputs.dependencies_max }} | |
run: | | |
if [ -z "$TOTAL" ] || [ -z "$TOTAL_MAX" ] || [ -z "$CONVENTIONS" ] || [ -z "$CONVENTIONS_MAX" ] || [ -z "$DOCUMENTATION" ] || [ -z "$DOCUMENTATION_MAX" ] || [ -z "$PLATFORMS" ] || [ -z "$PLATFORMS_MAX" ] || [ -z "$ANALYSIS" ] || [ -z "$ANALYSIS_MAX" ] || [ -z "$DEPENDENCIES" ] || [ -z "$DEPENDENCIES_MAX" ] | |
then | |
echo All the outputs have not been properly set | |
exit 1 | |
fi | |
if ! jq -e . >/dev/null 2>&1 <<< "$JSON_OUTPUT" | |
then | |
echo "Invalid JSON" | |
echo "$JSON_OUTPUT" | |
exit 1 | |
fi | |
if (( "$TOTAL" < "$TOTAL_MAX" )) | |
then | |
echo Total score can be improved | |
else | |
echo Perfect scores! | |
fi | |
test-with-paths: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
path: ["test", "/test", "./test"] | |
analysisoptions: ["analysis_options.yaml", ""] | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Build container | |
run: sudo docker build -f $DOCKERFILE -t $IMAGE . | |
- name: Run tests | |
env: | |
WORKSPACE: /tmp | |
run: | | |
sudo docker run -d -t --name test $IMAGE | |
sudo docker cp ${GITHUB_WORKSPACE}/test/. test:$WORKSPACE/test | |
sudo docker cp ${GITHUB_EVENT_PATH} test:$WORKSPACE/event.json | |
sudo docker exec -e GITHUB_RUN_NUMBER=$GITHUB_RUN_NUMBER -e GITHUB_EVENT_PATH=$WORKSPACE/event.json -e INPUT_RELATIVEPATH=${{ matrix.path }} -e INPUT_CUSTOMANALYSISOPTIONS=${{ matrix.analysisoptions }} -e GITHUB_WORKSPACE=$WORKSPACE -e GITHUB_SHA=$GITHUB_SHA -e GITHUB_REPOSITORY=$GITHUB_REPOSITORY -e INPUT_MINANNOTATIONLEVEL=info -e INPUT_GITHUBTOKEN=${{ secrets.GITHUB_TOKEN }} test /bin/bash -c "/dart_package_analyzer" | |
test-pubspec-error: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Build container | |
run: sudo docker build -f $DOCKERFILE -t $IMAGE . | |
- name: Run tests | |
continue-on-error: true | |
run: | | |
sudo docker run -d -t --name test $IMAGE | |
sudo docker cp ${GITHUB_WORKSPACE}/test/. test:/test | |
sudo docker cp ${GITHUB_EVENT_PATH} test:/event.json | |
sudo docker exec test /bin/bash -c "rm /test/pubspec.yaml" | |
sudo docker exec -e GITHUB_RUN_NUMBER=$GITHUB_RUN_NUMBER -e GITHUB_EVENT_PATH=/event.json -e GITHUB_WORKSPACE=/test -e GITHUB_SHA=$GITHUB_SHA -e GITHUB_REPOSITORY=$GITHUB_REPOSITORY -e INPUT_MINANNOTATIONLEVEL=info -e INPUT_GITHUBTOKEN=${{ secrets.GITHUB_TOKEN }} test /bin/bash -c "/dart_package_analyzer" |