Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
Test Runner
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ii
INF222
V23
Assignments
Test Runner
Compare revisions
a98189ca51c5833653334e55eb73803ea753c334 to 406bf62613b8240ebcb986a2ddfec62121827e38
Compare revisions
Changes are shown as if the
source
revision was being merged into the
target
revision.
Learn more about comparing revisions.
Source
ii/inf222/v23/assignments/test-runner
Select target project
No results found
406bf62613b8240ebcb986a2ddfec62121827e38
Select Git revision
Branches
main
Swap
Target
ii/inf222/v23/assignments/test-runner
Select target project
ii/inf222/v23/assignments/test-runner
1 result
a98189ca51c5833653334e55eb73803ea753c334
Select Git revision
Branches
main
Show changes
Only incoming changes from source
Include changes to target since source was created
Compare
Commits on Source (2)
skip wip tests
· f6903926
Anya Helene Bagge
authored
2 years ago
f6903926
skip wip tests
· 406bf626
Anya Helene Bagge
authored
2 years ago
406bf626
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
find_gitlab_users.py
+9
-2
9 additions, 2 deletions
find_gitlab_users.py
run-tests
+18
-8
18 additions, 8 deletions
run-tests
student_project_setup.py
+33
-8
33 additions, 8 deletions
student_project_setup.py
with
60 additions
and
18 deletions
find_gitlab_users.py
View file @
406bf626
...
...
@@ -33,7 +33,7 @@ for row in rows:
name
=
row
[
'
sortable_name
'
]
(
lastname
,
firstname
)
=
[
s
.
strip
()
for
s
in
name
.
split
(
'
,
'
,
1
)]
(
first_firstname
,
*
more_firstnames
)
=
firstname
.
split
()
if
row
.
get
(
'
user
id
'
,
''
)
==
''
:
if
row
.
get
(
'
git
id
'
,
''
)
==
''
:
row
[
'
gituser
'
]
=
''
users
=
gl
.
users
.
list
(
username
=
row
[
'
email
'
].
replace
(
'
@uib.no
'
,
''
).
replace
(
'
@student.uib.no
'
,
''
))
...
...
@@ -41,13 +41,18 @@ for row in rows:
if
len
(
users
)
==
1
:
user
=
users
[
0
]
else
:
more_users
=
gl
.
users
.
list
(
username
=
f
'
{
first_firstname
}
.
{
lastname
}
'
)
more_users
=
gl
.
users
.
list
(
username
=
row
[
'
login_id
'
]
)
if
len
(
more_users
)
==
1
:
user
=
more_users
[
0
]
else
:
more_users
=
gl
.
users
.
list
(
username
=
f
'
{
first_firstname
}
.
{
lastname
}
'
)
if
len
(
more_users
)
==
1
:
user
=
more_users
[
0
]
if
user
:
row
[
'
gituser
'
]
=
user
.
username
row
[
'
gitid
'
]
=
user
.
id
print
(
"
Found
"
,
format_user
(
row
))
elif
len
(
users
)
==
0
:
if
'
uib.no
'
in
row
[
'
email
'
]:
missing
.
append
(
row
)
...
...
@@ -76,6 +81,8 @@ if 'gituser' not in fieldnames:
fieldnames
.
append
(
'
gituser
'
)
if
'
gitid
'
not
in
fieldnames
:
fieldnames
.
append
(
'
gitid
'
)
if
'
gitoverride
'
not
in
fieldnames
:
fieldnames
.
append
(
'
gitoverride
'
)
with
open
(
'
students.csv
'
,
'
w
'
)
as
csvfile
:
writer
=
csv
.
DictWriter
(
csvfile
,
fieldnames
)
...
...
This diff is collapsed.
Click to expand it.
run-tests
View file @
406bf626
...
...
@@ -6,6 +6,8 @@
# Usage: run-tests [compile] [test]
#
BUILD_SUCCESSES
=
0
BUILD_FAILURES
=
0
SUCCESSES
=
0
FAILURES
=
0
...
...
@@ -15,18 +17,21 @@ compile()
echo
"==========Compiling Test Files=========="
echo
"----------------------------------------"
for
i
in
$(
cd
"
$TEST_DIR
"
;
find
.
-name
'*_Test*.hs'
)
;
do
[
-d
"
$REPORT_DIR
"
]
||
mkdir
-p
"
$REPORT_DIR
"
for
i
in
$(
cd
"
$TEST_DIR
"
;
find
.
-name
'wip*'
-prune
-o
-name
'*_Test*.hs'
-print
)
;
do
i
=
"
${
i
#./
}
"
# strip leading ./
o
=
"
${
i
%.hs
}
"
# strip trailing .hs
r
=
$(
echo
"
$o
"
|
sed
-e
's;/;_;g'
)
# / → _
mkdir
-p
"
$BUILD_DIR
/
$(
dirname
$o
)
"
echo
"--Compiling
$i
to
$o
---"
if
ghc
-i
"
$STUDENT_DIR
"
--make
"
$TEST_DIR
/
$i
"
-o
"
$BUILD_DIR
/
$o
"
;
then
SUCCESSES
=
$((
SUCCESSES
+
1
))
if
ghc
-i
"
$STUDENT_DIR
"
--make
"
$TEST_DIR
/
$i
"
-o
"
$BUILD_DIR
/
$o
"
|
tee
"
$REPORT_DIR
/
${
r
}
_ghc.log"
;
then
BUILD_
SUCCESSES
=
$((
BUILD_
SUCCESSES
+
1
))
else
FAILURES
=
$((
FAILURES
+
1
))
BUILD_
FAILURES
=
$((
BUILD_
FAILURES
+
1
))
fi
done
...
...
@@ -83,6 +88,9 @@ while [ $# -gt 0 ]; do
elif
[
"
$1
"
=
"test"
]
;
then
run_tests
shift
elif
[
"
$1
"
=
"clean"
]
;
then
rm
-rf
"
$BUILD_DIR
"
shift
elif
[
"
$1
"
=
"-s"
]
;
then
shift
STUDENT_DIR
=
"
$1
"
...
...
@@ -93,14 +101,16 @@ while [ $# -gt 0 ]; do
shift
else
echo
>>
/dev/stderr Bad argument:
"
$1
"
echo
>>
/dev/stderr usage: run-tests
[
-t
TEST_DIR]
[
-s
STUDENT_DIR]
[
compile]
[
test
]
echo
>>
/dev/stderr usage: run-tests
[
-t
TEST_DIR]
[
-s
STUDENT_DIR]
[
compile]
[
test
]
[
clean]
exit
1
fi
done
echo
$SUCCESSES
successful tests,
$FAILURES
failures
if
[
$BUILD_FAILURES
-gt
0
]
;
then
echo
$BUILD_FAILURES
tests failed to build
fi
echo
$SUCCESSES
successful tests,
$FAILURES
test
failures
echo
"========================================"
echo
"@-----------------DONE-----------------@"
echo
"========================================"
[
$FAILURES
-eq
0
]
# set exit code
[
$FAILURES
-eq
0
]
&&
[
$BUILD_FAILURES
-eq
0
]
# set exit code
This diff is collapsed.
Click to expand it.
student_project_setup.py
View file @
406bf626
...
...
@@ -119,6 +119,7 @@ class AssignmentFork:
def
check_membership
(
self
,
resource
:
Project
|
Group
,
user
:
User
|
CurrentUser
|
int
):
user_id
=
getattr
(
user
,
'
id
'
,
user
)
#logger.debug('checking membership for %s %s %s', user, resource, user_id)
try
:
membership
=
resource
.
members
.
get
(
user_id
)
if
membership
.
access_level
!=
gitlab
.
const
.
OWNER_ACCESS
and
membership
.
access_level
!=
self
.
access_level
:
...
...
@@ -238,23 +239,24 @@ class AssignmentFork:
except
gitlab
.
GitlabError
as
e
:
self
.
__failed
(
e
,
self
.
assignment
)
def
check_user_project
(
self
,
user
:
User
|
CurrentUser
|
str
|
int
):
def
check_user_project
(
self
,
user
:
User
|
CurrentUser
|
str
|
int
,
details
=
False
,
override_project_username
=
None
):
try
:
return
self
.
__check_user_project
(
self
.
get_user
(
user
))
return
self
.
__check_user_project
(
self
.
get_user
(
user
)
,
details
,
override_project_username
)
except
gitlab
.
GitlabError
as
e
:
self
.
__failed
(
e
,
user
)
def
__check_user_project
(
self
,
user
:
User
|
CurrentUser
):
def
__check_user_project
(
self
,
user
:
User
|
CurrentUser
,
details
:
bool
,
override_project_username
:
str
|
None
):
config
=
self
.
gitlab_config
.
copy
()
try
:
config
[
'
name
'
]
=
f
'
{
user
.
username
}
–
{
self
.
assignment
.
name
}
'
project_slug
=
f
'
{
user
.
username
}
_
{
self
.
assignment
.
path
}
'
project_slug
=
f
'
{
override_project_username
or
user
.
username
}
_
{
self
.
assignment
.
path
}
'
self
.
_last_user
=
user
self
.
_last_project
=
project
=
self
.
gl
.
projects
.
get
(
f
'
{
self
.
namespace
[
"
full_path
"
]
}
/
{
project_slug
}
'
)
logger
.
debug
(
'
Found project %s for user %s
'
,
project
.
path_with_namespace
,
user
.
username
)
except
GitlabGetError
:
details
=
True
url
=
self
.
assignment
.
ssh_url_to_repo
.
replace
(
f
'
/
{
self
.
assignment
.
path
}
.git
'
,
f
'
/
{
project_slug
}
.git
'
)
desc
=
self
.
assignment
.
description
...
...
@@ -277,7 +279,7 @@ class AssignmentFork:
else
:
project
=
None
self
.
__change
(
'
add_fork
'
,
project
,
source
=
self
.
assignment
)
if
project
!=
None
:
if
project
!=
None
and
details
:
self
.
check_project_setup
(
user
,
project
,
config
)
return
project
...
...
@@ -308,16 +310,29 @@ if __name__ == '__main__':
args
=
sys
.
argv
[
1
:]
file
=
None
assignment
=
None
while
len
(
args
)
>
1
:
details
=
False
skip
=
0
while
len
(
args
)
>
0
:
if
args
[
0
]
==
'
-f
'
:
file
=
args
[
1
]
print
(
'
Students file:
'
,
file
)
args
=
args
[
2
:]
elif
args
[
0
]
==
'
-a
'
:
assignment
=
args
[
1
]
print
(
'
Assignment:
'
,
assignment
)
args
=
args
[
2
:]
elif
args
[
0
]
==
'
-d
'
:
print
(
'
Details enabled!
'
)
details
=
True
args
=
args
[
1
:]
elif
args
[
0
]
==
'
-s
'
:
skip
=
int
(
args
[
1
])
print
(
'
Skipping
'
,
skip
)
args
=
args
[
2
:]
else
:
raise
ValueError
(
args
[
0
])
projects
:
list
[
tuple
[
str
,
Project
|
None
]]
=
[]
if
file
==
None
:
print
(
"
Missing input file
"
)
elif
assignment
==
None
:
...
...
@@ -331,9 +346,19 @@ if __name__ == '__main__':
n
=
0
for
row
in
reader
:
if
row
[
'
gitid
'
].
isdigit
():
assignment
.
check_user_project
(
int
(
row
[
'
gitid
'
]))
time
.
sleep
(
1
)
print
(
n
,
row
)
if
n
>=
skip
:
proj
=
assignment
.
check_user_project
(
int
(
row
[
'
gitid
'
]),
details
,
row
.
get
(
'
gitoverride
'
))
projects
.
append
((
row
.
get
(
'
gitoverride
'
)
or
row
[
'
gituser
'
],
proj
))
if
details
:
time
.
sleep
(
1
)
else
:
time
.
sleep
(
0.01
)
n
=
n
+
1
with
open
(
'
project-links.txt
'
,
'
w
'
)
as
f
:
for
u
,
p
in
projects
:
if
p
:
f
.
write
(
f
'
{
u
}
{
p
.
ssh_url_to_repo
}
\n
'
)
finally
:
with
open
(
'
changes.txt
'
,
'
w
'
)
as
f
:
f
.
write
(
pformat
(
assignment
.
changelog
,
sort_dicts
=
False
))
...
...
This diff is collapsed.
Click to expand it.