-
-
Notifications
You must be signed in to change notification settings - Fork 33
Running smoke tests in docker #266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
5fb8d8e
Add expected output in test_data
jiegillet b047a8c
Adding tests in docker
jiegillet 6249fbd
Add test in CI
jiegillet d297f83
Rename step and name
jiegillet adba91f
Smoke test stops at first failure
jiegillet cad0cfd
Add clock config file for perfect solution
jiegillet 552a826
Ignore analyzer warnings, only compare analysis file
jiegillet ba8ca3b
Revert "Ignore analyzer warnings, only compare analysis file"
jiegillet c6d28a4
remove read-only
jiegillet 120a3d9
Try using full path
jiegillet 6b9e340
Write output to /tmp
jiegillet 0f33d9c
Revert "remove read-only"
jiegillet 41626bb
Revert "Revert "remove read-only""
jiegillet 7115893
match read-only production flag
jiegillet File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| exercise=$1 | ||
|
|
||
| function installed { | ||
| cmd=$(command -v "${1}") | ||
|
|
||
| [[ -n "${cmd}" ]] && [[ -f "${cmd}" ]] | ||
| return ${?} | ||
| } | ||
|
|
||
| function die { | ||
| >&2 echo "Fatal: ${@}" | ||
| exit 1 | ||
| } | ||
|
|
||
| function main { | ||
| expected_files=(/tmp/${exercise}/analysis.json ${exercise}/expected_analysis.json) | ||
|
|
||
| for file in ${expected_files[@]}; do | ||
| if [[ ! -f "${file}" ]]; then | ||
| echo "🔥 ${exercise}: expected ${file} to exist on successful run 🔥" | ||
| exit 1 | ||
| fi | ||
| done | ||
|
|
||
| if ! diff <(jq -S . ${exercise}/expected_analysis.json) <(jq -S . /tmp/${exercise}/analysis.json); then | ||
| echo "🔥 ${exercise}: expected /tmp/${exercise}/analysis.json to equal ${exercise}/expected_analysis.json on successful run 🔥" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "🏁 ${exercise}: expected files present after successful run 🏁" | ||
| } | ||
|
|
||
| # Check for all required dependencies | ||
| deps=(diff jq) | ||
| for dep in "${deps[@]}"; do | ||
| installed "${dep}" || die "Missing '${dep}'" | ||
| done | ||
|
|
||
| main "$@"; exit |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| # Synopsis: | ||
| # Test the analyzer Docker image by running it against a predefined set of | ||
| # solutions with an expected output. | ||
| # The analyzer Docker image is built automatically. | ||
|
|
||
| # Output: | ||
| # Outputs the diff of the expected test results against the actual test results | ||
| # generated by the test runner Docker image. | ||
|
|
||
| # Example: | ||
| # ./bin/run-tests-in-docker.sh | ||
|
|
||
| set -e # Make script exit when a command fail. | ||
| set -u # Exit on usage of undeclared variable. | ||
| # set -x # Trace what gets executed. | ||
| set -o pipefail # Catch failures in pipes. | ||
|
|
||
| # build docker image | ||
| docker build --rm -t elixir-analyzer . | ||
|
|
||
| # run image passing the arguments | ||
| docker run \ | ||
| --rm \ | ||
| --network none \ | ||
| --read-only \ | ||
| --mount type=bind,src=$(realpath test_data),dst=/opt/analyzer/test_data \ | ||
| --mount type=tmpfs,dst=/tmp \ | ||
| --entrypoint /opt/analyzer/bin/smoke_test.sh \ | ||
| elixir-analyzer | ||
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| set -e # Make script exit when a command fail. | ||
| set -u # Exit on usage of undeclared variable. | ||
| # set -x # Trace what gets executed. | ||
| set -o pipefail # Catch failures in pipes. | ||
|
|
||
| for solution in test_data/*/* ; do | ||
| slug=$(basename $(dirname $solution)) | ||
| mkdir -p /tmp/$solution | ||
| # run analysis | ||
| bin/run.sh $slug $solution /tmp/$solution | ||
| # check result | ||
| bin/check_files.sh $solution | ||
| done |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| { | ||
| "blurb": "Implement a clock that handles times without dates.", | ||
| "authors": [ | ||
| "tejasbubane" | ||
| ], | ||
| "contributors": [ | ||
| "angelikatyborska", | ||
| "Cohen-Carlisle", | ||
| "devonestes", | ||
| "nathanchere", | ||
| "neenjaw", | ||
| "parkerl", | ||
| "sotojuan" | ||
| ], | ||
| "files": { | ||
| "solution": [ | ||
| "lib/clock.ex" | ||
| ], | ||
| "test": [ | ||
| "test/clock_test.exs" | ||
| ], | ||
| "example": [ | ||
| ".meta/example.ex" | ||
| ] | ||
| }, | ||
| "source": "Pairing session with Erin Drummond", | ||
| "source_url": "https://twitter.com/ebdrummond" | ||
| } |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {"comments":[],"summary":"Submission analyzed. No automated suggestions found."} |
File renamed without changes.
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {"comments":[{"comment":"elixir.solution.compiler_warnings","params":{"warnings":"warning: Behaviour.defcallback/1 is deprecated. Use the @callback module attribute instead\n test_data/lasagna/deprecated_modules/lib/lasagna.ex:4: Lasagna\n\nwarning: HashDict.new/0 is deprecated. Use maps and the Map module instead\n test_data/lasagna/deprecated_modules/lib/lasagna.ex:7: Lasagna.expected_minutes_in_oven/0\n\nwarning: HashSet.member?/2 is deprecated. Use the MapSet module instead\n test_data/lasagna/deprecated_modules/lib/lasagna.ex:12: Lasagna.remaining_minutes_in_oven/1\n\nwarning: HashSet.new/0 is deprecated. Use the MapSet module instead\n test_data/lasagna/deprecated_modules/lib/lasagna.ex:12: Lasagna.remaining_minutes_in_oven/1\n\n"},"type":"actionable"}],"summary":"Check the comments for some suggestions. 📣"} |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {"comments":[{"comment":"elixir.lasagna.function_reuse","type":"actionable"},{"comment":"elixir.solution.private_helper_functions","params":{"actual":"def public_helper(_)","expected":"defp public_helper(_)"},"type":"informative"},{"comment":"elixir.solution.todo_comment","type":"informative"}],"summary":"Check the comments for some suggestions. 📣"} |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {"comments":[],"summary":"Analysis was halted. Analysis skipped, not able to read solution config."} |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {"comments":[],"summary":"Submission analyzed. No automated suggestions found."} |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {"comments":[{"comment":"elixir.solution.same_as_exemplar","type":"celebratory"}],"summary":"You're doing something right. 🎉"} |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {"comments":[],"summary":"Analysis was halted. Analysis skipped, not able to decode solution config."} |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {"comments":[],"summary":"Analysis was halted. Analysis skipped, unexpected error Elixir.ArgumentError"} |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {"comments":[],"summary":"Submission analyzed. No automated suggestions found."} |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {"comments":[{"comment":"elixir.general.parsing_error","params":{"error":"missing terminator: end (for \"do\" starting at line 1)","line":14},"type":"essential"}],"summary":"Check the comments for things to fix. 🛠"} |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {"comments":[{"comment":"elixir.solution.raise_fn_clause_error","type":"actionable"},{"comment":"elixir.solution.variable_name_snake_case","params":{"actual":"_nameInPascalCase","expected":"_name_in_pascal_case"},"type":"actionable"},{"comment":"elixir.solution.module_attribute_name_snake_case","params":{"actual":"someUnusedModuleAttribute","expected":"some_unused_module_attribute"},"type":"actionable"},{"comment":"elixir.solution.module_pascal_case","params":{"actual":"My_empty_module","expected":"MyEmptyModule"},"type":"actionable"},{"comment":"elixir.solution.compiler_warnings","params":{"warnings":"warning: module attribute @someUnusedModuleAttribute was set but never used\n test_data/two_fer/imperfect_solution/lib/two_fer.ex:2\n\n"},"type":"actionable"},{"comment":"elixir.solution.indentation","type":"informative"},{"comment":"elixir.solution.private_helper_functions","params":{"actual":"def public_helper(_)","expected":"defp public_helper(_)"},"type":"informative"}],"summary":"Check the comments for some suggestions. 📣"} |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {"comments":[],"summary":"Submission analyzed. No automated suggestions found."} |
1 change: 1 addition & 0 deletions
1
test_data/two_fer/missing_example_solution/expected_analysis.json
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {"comments":[],"summary":"Submission analyzed. No automated suggestions found."} |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {"comments":[{"comment":"elixir.general.file_not_found","params":{"file_name":"two_fer.ex","path":"test_data/two_fer/missing_file_solution"},"type":"essential"}],"summary":"Check the comments for things to fix. 🛠"} |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {"comments":[],"summary":"Submission analyzed. No automated suggestions found."} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 (sanity check: the script fails when either the first or the second stage of the docker build fails, which was the problem Erik wanted to address)