generated from actions/container-action
-
Notifications
You must be signed in to change notification settings - Fork 9
98 lines (88 loc) · 4.72 KB
/
test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# 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@v4
- name: Build container
run: sudo docker build --quiet -f $DOCKERFILE -t $IMAGE .
- name: Run tests
id: steptest
run: |
sudo docker run -d -t --name test-container $IMAGE
sudo docker cp ${GITHUB_WORKSPACE}/test/. test-container:/test
sudo docker cp ${GITHUB_EVENT_PATH} test-container:/event.json
sudo docker exec test-container /bin/bash -c "cd /test && git init"
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-container /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@v4
- name: Build container
run: sudo docker build --quiet -f $DOCKERFILE -t $IMAGE .
- name: Run tests
env:
WORKSPACE: /tmp
run: |
sudo docker run -d -t --name test-container $IMAGE
sudo docker cp ${GITHUB_WORKSPACE}/test/. test-container:$WORKSPACE/test
sudo docker cp ${GITHUB_EVENT_PATH} test-container:$WORKSPACE/event.json
sudo docker exec test-container /bin/bash -c "cd $WORKSPACE/test && git init"
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-container /bin/bash -c "/dart_package_analyzer"
test-pubspec-error:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build container
run: sudo docker build --quiet -f $DOCKERFILE -t $IMAGE .
- name: Run tests
continue-on-error: true
run: |
sudo docker run -d -t --name test-container $IMAGE
sudo docker cp ${GITHUB_WORKSPACE}/test/. test-container:/test
sudo docker cp ${GITHUB_EVENT_PATH} test-container:/event.json
sudo docker exec test-container /bin/bash -c "cd /test && git init"
sudo docker exec test-container /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-container /bin/bash -c "/dart_package_analyzer"