Skip to content

Commit ed65ddf

Browse files
committed
Adapt the unit test action to not use a docker image.
1 parent 96d631f commit ed65ddf

19 files changed

+128
-71
lines changed

.github/workflows/unit-tests.yml

Lines changed: 57 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,85 @@ name: Unit Tests and Coverage
22

33
on:
44
push:
5-
branches: [ main ]
5+
branches: [main]
66
pull_request:
7-
branches: [ main ]
7+
branches: [main]
88

99
jobs:
1010
unit-tests:
11-
runs-on: ubuntu-latest
12-
# If we are going to use a prebuilt image like this we need a webwork repository on docker hub
13-
container: drgrice1/webwork3
11+
runs-on: ubuntu-20.04
1412
steps:
15-
- uses: actions/checkout@v2
13+
- name: Checkout webwork3 source code
14+
uses: actions/checkout@v2
15+
16+
# Disabling these things speeds up the setup considerably, and they are not needed for the throw away machine.
17+
- name: Disable man-db and initramfs updates
18+
run: |
19+
sudo sed -i 's/yes/no/g' /etc/initramfs-tools/update-initramfs.conf
20+
sudo rm -f /var/lib/man-db/auto-update
21+
22+
- name: Install dependencies
23+
run: |
24+
sudo apt-get update
25+
sudo apt-get install -qy --no-install-recommends --no-install-suggests \
26+
cpanminus \
27+
libarray-utils-perl \
28+
libcapture-tiny-perl \
29+
libclass-accessor-lite-perl \
30+
libclone-perl \
31+
libcrypt-ssleay-perl \
32+
libdata-dump-perl \
33+
libdatetime-format-strptime-perl \
34+
libdbd-sqlite3-perl \
35+
libdbix-class-inflatecolumn-serializer-perl \
36+
libdbix-class-perl \
37+
libdbix-dbschema-perl \
38+
libdevel-cover-perl \
39+
libexception-class-perl \
40+
libextutils-config-perl \
41+
libextutils-helpers-perl \
42+
libextutils-installpaths-perl \
43+
libfurl-perl \
44+
libhttp-parser-xs-perl \
45+
libio-socket-ssl-perl \
46+
liblist-moreutils-perl \
47+
libmodule-build-tiny-perl \
48+
libnet-ssleay-perl \
49+
libsql-translator-perl \
50+
libtest-exception-perl \
51+
libtest-harness-perl \
52+
libtext-csv-perl \
53+
libtry-tiny-perl \
54+
libyaml-libyaml-perl
55+
cpanm --sudo --notest \
56+
DBIx::Class::DynamicSubclass \
57+
Mojolicious \
58+
Mojolicious::Plugin::NotYAMLConfig \
59+
Mojolicious::Plugin::DBIC \
60+
Mojolicious::Plugin::Authentication \
61+
Devel::Cover::Report::Codecov
62+
1663
- name: Run perl unit tests
1764
env:
1865
HARNESS_PERL_SWITCHES: -MDevel::Cover
1966
run: |
2067
perl t/db/build_db.pl
2168
prove -r t
2269
23-
# we probably don'te need to upload the codecov data
24-
# - uses: actions/upload-artifact@v2
25-
# with:
26-
# name: coverage-report
27-
# path: cover_db/
28-
2970
- name: Push coverage analysis
3071
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
3172
env:
3273
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
3374
run: cover -report codecov
3475

35-
# Install node (for npm) and use it to install eslint and stylelint dependencies.
36-
- name: Use Node.js
76+
# Install node (for npm).
77+
- name: Set up node
3778
uses: actions/setup-node@v2
3879
with:
3980
node-version: '16'
81+
4082
- name: Install Dependencies
4183
run: npm ci
84+
4285
- name: Run typescript (client-side) tests
4386
run: npm run test

docker/webwork3.dockerfile

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,49 @@
11
FROM ubuntu:20.04
22

3-
# the following are needed to make sure the timezone packages don't ask for your timezone.
3+
# The following are needed to make sure the timezone packages don't ask for your timezone.
44
ENV DEBIAN_FRONTEND noninteractive
55
ENV DEBCONF_NONINTERACTIVE_SEEN true
66
ENV HARNESS_PERL_SWITCHES -MDevel::Cover
77

88
RUN apt-get update && \
99
apt-get install -qy --no-install-recommends --no-install-suggests \
1010
build-essential=12.8ubuntu1 \
11-
ca-certificates=20210119~20.04.1 \
11+
ca-certificates=20211016~20.04.1 \
1212
cpanminus=1.7044-1 \
13-
git=1:2.25.1-1ubuntu3.1 \
13+
git=1:2.25.1-1ubuntu3.5 \
1414
libarray-utils-perl=0.5-1 \
15+
libcapture-tiny-perl=0.48-1 \
16+
libclass-accessor-lite-perl=0.08-1 \
1517
libclone-perl=0.43-2 \
1618
libcrypt-ssleay-perl=0.73.06-1build3 \
1719
libdata-dump-perl=1.23-1 \
1820
libdatetime-format-strptime-perl=1.7600-1 \
19-
libdbd-mysql-perl=4.050-3 \
21+
# libdbd-mysql-perl=4.050-3 \
2022
libdbd-sqlite3-perl=1.64-1build1 \
21-
libdbix-class-perl=0.082841-1 \
2223
libdbix-class-inflatecolumn-serializer-perl=0.09-1 \
24+
libdbix-class-perl=0.082841-1 \
2325
libdbix-dbschema-perl=0.45-1 \
2426
libdevel-cover-perl=1.33-1build1 \
2527
libexception-class-perl=1.44-1 \
2628
libjson-perl=4.02000-2 \
29+
libjson-xs-perl=4.020-1build1 \
30+
libextutils-config-perl=0.008-2 \
31+
libextutils-helpers-perl=0.026-1 \
32+
libextutils-installpaths-perl=0.012-1 \
33+
libfurl-perl=3.13-2 \
34+
libhttp-parser-xs-perl=0.17-1build5 \
35+
libio-socket-ssl-perl=2.067-1 \
36+
libmodule-build-tiny-perl=0.039-1 \
2737
libnet-ssleay-perl=1.88-2ubuntu1 \
2838
libsql-translator-perl=1.60-1 \
29-
libssl-dev=1.1.1f-1ubuntu2.5 \
39+
libssl-dev=1.1.1f-1ubuntu2.16 \
3040
libtest-exception-perl=0.43-1 \
3141
libtest-harness-perl=3.42-2 \
3242
libtext-csv-perl=2.00-1 \
3343
libtry-tiny-perl=0.30-1 \
3444
libyaml-libyaml-perl=0.81+repack-1 \
3545
# mariadb-server=1:10.3.31-0ubuntu0.20.04.1 \ # if desired to use a full database
36-
openssl=1.1.1f-1ubuntu2.5 && \
46+
openssl=1.1.1f-1ubuntu2.16 && \
3747
rm -rf /var/lib/apt/lists/* && \
3848
cpanm --notest \
3949
DBIx::Class::DynamicSubclass \

lib/DB/Schema/Result/Attempt.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ Note: a problem should have only one of a library_id, problem_path or problem_po
5959

6060
__PACKAGE__->table('attempt');
6161

62-
__PACKAGE__->load_components('InflateColumn::Serializer', 'Core');
62+
__PACKAGE__->load_components(qw/InflateColumn::Serializer Core/);
6363

6464
__PACKAGE__->add_columns(
6565
attempt_id => {

lib/DB/Schema/Result/CourseSettings.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ C<email>: a JSON object that stores email settings
4949

5050
__PACKAGE__->table('course_settings');
5151

52-
__PACKAGE__->load_components('InflateColumn::Serializer', 'Core');
52+
__PACKAGE__->load_components(qw/InflateColumn::Serializer Core/);
5353

5454
__PACKAGE__->add_columns(
5555
course_settings_id => {

lib/DB/Schema/Result/CourseUser.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ C<showOldAnswers>: whether or not the user shows old answer (boolean)
8888

8989
__PACKAGE__->table('course_user');
9090

91-
__PACKAGE__->load_components('InflateColumn::Serializer', 'Core');
91+
__PACKAGE__->load_components(qw/InflateColumn::Serializer Core/);
9292

9393
__PACKAGE__->add_columns(
9494
course_user_id => {

lib/DB/Schema/Result/PoolProblem.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Note: the C<params> can only have one of the two fields
4848

4949
__PACKAGE__->table('pool_problem');
5050

51-
__PACKAGE__->load_components('InflateColumn::Serializer', 'Core');
51+
__PACKAGE__->load_components(qw/InflateColumn::Serializer Core/);
5252

5353
__PACKAGE__->add_columns(
5454
pool_problem_id => {

lib/DB/Schema/Result/ProblemSet.pm

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,9 @@ L<DB::Schema::Result::ProblemSet::ReviewSet> which gives properties common to re
7171
7272
=cut
7373

74-
__PACKAGE__->load_components(qw/DynamicSubclass Core/);
75-
7674
__PACKAGE__->table('problem_set');
7775

78-
__PACKAGE__->load_components(qw/DynamicSubclass Core/, qw/InflateColumn::Serializer Core/);
76+
__PACKAGE__->load_components(qw/DynamicSubclass Core InflateColumn::Serializer InflateColumn::Boolean Core/);
7977

8078
__PACKAGE__->add_columns(
8179
set_id => {

lib/DB/Schema/Result/SetProblem.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ Note: a problem should have only one of a library_id, problem_path or problem_po
6565

6666
__PACKAGE__->table('set_problem');
6767

68-
__PACKAGE__->load_components('InflateColumn::Serializer', 'Core');
68+
__PACKAGE__->load_components(qw/InflateColumn::Serializer Core/);
6969

7070
__PACKAGE__->add_columns(
7171
set_problem_id => {

lib/DB/Schema/Result/UserProblem.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use base qw/DBIx::Class::Core DB::Validation/;
1515

1616
__PACKAGE__->table('user_problem');
1717

18-
__PACKAGE__->load_components('InflateColumn::Serializer', 'Core');
18+
__PACKAGE__->load_components(qw/InflateColumn::Serializer Core/);
1919

2020
__PACKAGE__->add_columns(
2121
user_problem_id => {

lib/DB/Schema/Result/UserSet.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ types have different params fields.
5858

5959
__PACKAGE__->table('user_set');
6060

61-
__PACKAGE__->load_components('InflateColumn::Serializer', 'Core');
61+
__PACKAGE__->load_components(qw/InflateColumn::Serializer InflateColumn::Boolean Core/);
6262

6363
__PACKAGE__->add_columns(
6464
user_set_id => {

t/db/001_courses.t

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use Test::More;
1818
use Test::Exception;
1919
use YAML::XS qw/LoadFile/;
2020
use DateTime::Format::Strptime;
21+
use Mojo::JSON qw/true false/;
2122

2223
use DB::Schema;
2324

@@ -90,7 +91,7 @@ throws_ok {
9091
# Add a course
9192
my $new_course_params = {
9293
course_name => 'Geometry',
93-
visible => 1,
94+
visible => true,
9495
course_dates => {}
9596
};
9697

t/db/004_course_users.t

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ my $user_rs = $schema->resultset('User');
4242
# Get a list of users from the CSV file
4343
my @students = loadCSV("$main::ww3_dir/t/db/sample_data/students.csv");
4444
for my $student (@students) {
45-
$student->{is_admin} = 0;
45+
$student->{is_admin} = false;
4646
$student->{course_user_params} = $student->{params};
4747
delete $student->{params};
4848
}
@@ -124,7 +124,7 @@ my $user_params = {
124124
last_name => 'Quimby',
125125
email => '[email protected]',
126126
student_id => '12345',
127-
is_admin => 0
127+
is_admin => false
128128
};
129129

130130
my $course_user_params = {

t/db/006_quizzes.t

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,13 @@ my $user_rs = $schema->resultset('User');
4545

4646
my @all_problem_sets;
4747

48-
my @quizzes = loadCSV("$main::ww3_dir/t/db/sample_data/quizzes.csv");
48+
my @quizzes = loadCSV(
49+
"$main::ww3_dir/t/db/sample_data/quizzes.csv",
50+
{
51+
boolean_fields => ['set_visible'],
52+
param_boolean_fields => ['timed']
53+
}
54+
);
4955
for my $quiz (@quizzes) {
5056
$quiz->{set_type} = 'QUIZ';
5157
}
@@ -248,7 +254,7 @@ my $updated_quiz = $problem_set_rs->updateProblemSet(
248254
params => $updated_params
249255
);
250256

251-
$new_quiz->{set_visible} = 0;
257+
$new_quiz->{set_visible} = false;
252258
$new_quiz->{set_params} = {};
253259
removeIDs($updated_quiz);
254260
is_deeply($new_quiz, $updated_quiz, 'updateQuiz: successfully update the quiz');

t/mojolicious/001_login.t

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ use Mojo::Base -strict;
55
use Test::More;
66
use Test::Mojo;
77
use YAML::XS qw/LoadFile/;
8-
9-
use YAML::XS qw/LoadFile/;
8+
use Mojo::JSON qw/true false/;
109

1110
BEGIN {
1211
use File::Basename qw/dirname/;
@@ -36,11 +35,11 @@ $t->post_ok('/webwork3/api/login')->status_is(500, 'error status')->content_type
3635
$t->post_ok('/webwork3/api/login' => json => { username => 'lisa', password => 'lisa' })->status_is(200)
3736
->content_type_is('application/json;charset=UTF-8')->json_is(
3837
'' => {
39-
logged_in => 1,
38+
logged_in => true,
4039
user => {
4140
email => '[email protected]',
4241
first_name => 'Lisa',
43-
is_admin => 0,
42+
is_admin => false,
4443
last_name => 'Simpson',
4544
student_id => '23',
4645
user_id => 3,
@@ -53,7 +52,7 @@ $t->post_ok('/webwork3/api/login' => json => { username => 'lisa', password => '
5352
# Test logout
5453
$t->post_ok('/webwork3/api/logout')->status_is(200)->content_type_is('application/json;charset=UTF-8')->json_is(
5554
'' => {
56-
logged_in => 0,
55+
logged_in => false,
5756
message => 'Successfully logged out.'
5857
},
5958
'logout'
@@ -63,7 +62,7 @@ $t->post_ok('/webwork3/api/logout')->status_is(200)->content_type_is('applicatio
6362
$t->post_ok('/webwork3/api/login' => json => { username => 'lisa', password => 'wrong_password' })->status_is(200)
6463
->content_type_is('application/json;charset=UTF-8')->json_is(
6564
'' => {
66-
logged_in => 0,
65+
logged_in => false,
6766
message => 'Incorrect username or password.'
6867
},
6968
'invalid credentials'

t/mojolicious/002_courses.t

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ my $t = Test::Mojo->new(WeBWorK3 => $config);
2828

2929
# Authenticate with the admin user.
3030
$t->post_ok('/webwork3/api/login' => json => { username => 'admin', password => 'admin' })->status_is(200)
31-
->content_type_is('application/json;charset=UTF-8')->json_is('/logged_in' => 1)->json_is('/user/user_id' => 1)
32-
->json_is('/user/is_admin' => 1);
31+
->content_type_is('application/json;charset=UTF-8')->json_is('/logged_in' => true)->json_is('/user/user_id' => 1)
32+
->json_is('/user/is_admin' => true);
3333

3434
$t->get_ok('/webwork3/api/courses')->content_type_is('application/json;charset=UTF-8')
35-
->json_is('/0/course_name' => 'Precalculus')->json_is('/0/visible' => 1);
35+
->json_is('/0/course_name' => 'Precalculus')->json_is('/0/visible' => true);
3636

3737
$t->get_ok('/webwork3/api/courses/1')->content_type_is('application/json;charset=UTF-8')
38-
->json_is('/course_name' => 'Precalculus')->json_is('/visible' => 1);
38+
->json_is('/course_name' => 'Precalculus')->json_is('/visible' => true);
3939

4040
# Add a new course
4141
my $new_course = {
@@ -124,8 +124,8 @@ $t->get_ok('/webwork3/api/courses/4/settings')->status_is(200)->content_type_is(
124124
$t->post_ok('/webwork3/api/courses' => json => $new_course)->status_is(403)->json_is('/has_permission' => 0);
125125

126126
$t->put_ok('/webwork3/api/courses/4' => json => { course_name => 'XXX' })->status_is(403)
127-
->json_is('/has_permission' => false);
127+
->json_is('/has_permission' => 0);
128128

129-
$t->delete_ok('/webwork3/api/courses/4')->status_is(403)->json_is('/has_permission' => false);
129+
$t->delete_ok('/webwork3/api/courses/4')->status_is(403)->json_is('/has_permission' => 0);
130130

131131
done_testing;

0 commit comments

Comments
 (0)