Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
I
IQC.Jl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Package registry
Operate
Terraform modules
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Johan Grönqvist
IQC.Jl
Commits
73f2a7ab
Commit
73f2a7ab
authored
5 months ago
by
Johan Grönqvist
Browse files
Options
Downloads
Patches
Plain Diff
Add makefile rule to run tests on docker
parent
1900a251
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/Makefile
+39
-3
39 additions, 3 deletions
examples/Makefile
with
39 additions
and
3 deletions
examples/Makefile
+
39
−
3
View file @
73f2a7ab
...
@@ -12,8 +12,8 @@ SANITIZED_TESTS = $(shell echo $(TESTS) | sed 's/[ .]/_/g')
...
@@ -12,8 +12,8 @@ SANITIZED_TESTS = $(shell echo $(TESTS) | sed 's/[ .]/_/g')
# Define container name
# Define container name
CONTAINER_NAME
=
$(
CONTAINER_NAME_PREFIX
)$(
COMMIT
)
_
$(
SANITIZED_TESTS
)
CONTAINER_NAME
=
$(
CONTAINER_NAME_PREFIX
)$(
COMMIT
)
_
$(
SANITIZED_TESTS
)
.PHONY
:
run_tests
.PHONY
:
run_tests
_podman
run_tests
:
run_tests
_podman
:
@
if
[
-z
"
$(
TESTS
)
"
]
;
then
\
@
if
[
-z
"
$(
TESTS
)
"
]
;
then
\
echo
"Error: TESTS must be specified."
;
\
echo
"Error: TESTS must be specified."
;
\
exit
1
;
\
exit
1
;
\
...
@@ -54,10 +54,46 @@ run_tests:
...
@@ -54,10 +54,46 @@ run_tests:
podman stop
$(
CONTAINER_NAME
);
\
podman stop
$(
CONTAINER_NAME
);
\
podman
rm
$(
CONTAINER_NAME
)
podman
rm
$(
CONTAINER_NAME
)
.PHONY
:
run_tests_docker
run_tests_docker
:
@
if
[
-z
"
$(
TESTS
)
"
]
;
then
\
echo
"Error: TESTS must be specified."
;
\
exit
1
;
\
fi
@
if
[
-z
"
$(
COMMIT
)
"
]
;
then
\
echo
"Error: COMMIT must be specified."
;
\
exit
1
;
\
fi
@
echo
"Starting a new container for commit
$(
COMMIT
)
..."
docker run
--user
johan
-d
--name
$(
CONTAINER_NAME
)
\
$(
IMAGE
)
/bin/sh
-c
"sleep infinity"
docker
cp
$(
HOME
)
/.ssh/known_hosts
$(
CONTAINER_NAME
)
:/home/johan/.ssh/known_hosts
docker
exec
--user
johan
$(
CONTAINER_NAME
)
git clone
$(
REPO_URL
)
/home/johan/tmp/repo
docker
exec
--user
johan
$(
CONTAINER_NAME
)
bash
-c
"cd /home/johan/tmp/repo/ && git checkout
$(
COMMIT
)
"
for
test
in
$(
TESTS
);
do
\
echo
"Running test
$$
test..."
;
\
docker
exec
--user
johan
$(
CONTAINER_NAME
)
bash
-c
"cd /home/johan/tmp/repo/examples && nice -19 ionice -c 3
$(
JULIA_BIN
)
$$
test"
;
\
if
[
$$
?
-ne
0
]
;
then
\
echo
"Test
$$
test failed."
;
\
echo
"Set git tag with commands"
;
\
echo
"git tag -f test_failed_
$$
test
$(
COMMIT
)
"
;
\
docker stop
$(
CONTAINER_NAME
);
\
docker
rm
$(
CONTAINER_NAME
);
\
exit
1
;
\
fi
;
\
done
;
echo
"All tests
$(
TESTS
)
passed for commit
$(
COMMIT
)
."
;
\
echo
"Set git tags with commands"
;
\
for
test
in
$(
TESTS
);
do
\
echo
"git tag -f test_passed_
$$
test
$(
COMMIT
)
"
;
\
done
;
\
docker stop
$(
CONTAINER_NAME
);
\
docker
rm
$(
CONTAINER_NAME
)
# Clean target to remove old test containers if needed
# Clean target to remove old test containers if needed
.PHONY
:
clean
.PHONY
:
clean
clean
:
clean
:
@
podman ps
-a
--filter
"name=
$(
CONTAINER_NAME_PREFIX
)
*"
-q
| xargs podman
rm
-f
@
podman ps
-a
--filter
"name=
$(
CONTAINER_NAME_PREFIX
)
*"
-q
| xargs
-r
podman
rm
-f
@
docker ps
-a
--filter
"name=
$(
CONTAINER_NAME_PREFIX
)
*"
-q
| xargs
-r
docker
rm
-f
@
echo
"Cleaned up old test containers."
@
echo
"Cleaned up old test containers."
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment