Skip to content

Commit

Permalink
Adapt the unit test action to not use a docker image.
Browse files Browse the repository at this point in the history
This uses Ubuntu 22.04 for the runner and docker image.
  • Loading branch information
drgrice1 committed Nov 2, 2022
1 parent 4bad6ca commit b8bcaa6
Show file tree
Hide file tree
Showing 20 changed files with 231 additions and 94 deletions.
81 changes: 66 additions & 15 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
@@ -1,43 +1,94 @@
---
name: Unit Tests and Coverage

on:
push:
branches: [ main ]
branches: [main]
pull_request:
branches: [ main ]
branches: [main]

jobs:
unit-tests:
runs-on: ubuntu-latest
# If we are going to use a prebuilt image like this we need a webwork repository on docker hub
container: drgrice1/webwork3
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- name: Checkout webwork3 source code
uses: actions/checkout@v3

# Disabling these things speeds up the setup considerably, and they are not needed for the throw away machine.
- name: Disable man-db and initramfs updates
run: |
sudo sed -i 's/yes/no/g' /etc/initramfs-tools/update-initramfs.conf
sudo rm -f /var/lib/man-db/auto-update
- name: Install dependencies
env:
DEBIAN_FRONTEND: noninteractive
DEBCONF_NONINTERACTIVE_SEEN: true
DEBCONF_NOWARNINGS: yes
run: |
sudo apt-get update
sudo apt-get install -qy --no-install-recommends --no-install-suggests \
cpanminus \
libarray-utils-perl \
libcanary-stability-perl \
libcapture-tiny-perl \
libclass-accessor-lite-perl \
libclone-perl \
libcpanel-json-xs-perl \
libcrypt-ssleay-perl \
libdata-dump-perl \
libdatetime-format-strptime-perl \
libdbd-sqlite3-perl \
libdbix-class-inflatecolumn-serializer-perl \
libdbix-class-perl \
libdbix-dbschema-perl \
libdevel-cover-perl \
libexception-class-perl \
libextutils-config-perl \
libextutils-helpers-perl \
libextutils-installpaths-perl \
libfurl-perl \
libhttp-parser-xs-perl \
libimporter-perl \
libio-socket-ssl-perl \
liblist-moreutils-perl \
libmodule-build-tiny-perl \
libmojolicious-perl \
libmojolicious-plugin-authentication-perl \
libnet-ssleay-perl \
libsql-translator-perl \
libtest-exception-perl \
libtest-harness-perl \
libtext-csv-perl \
libtry-tiny-perl \
libyaml-libyaml-perl
cpanm --sudo --notest \
DBIx::Class::DynamicSubclass \
Mojolicious::Plugin::DBIC \
Mojolicious::Plugin::NotYAMLConfig \
Devel::Cover::Report::Codecov
- name: Run perl unit tests
env:
HARNESS_PERL_SWITCHES: -MDevel::Cover
run: |
perl t/db/build_db.pl
prove -r t
# we probably don'te need to upload the codecov data
# - uses: actions/upload-artifact@v2
# with:
# name: coverage-report
# path: cover_db/

- name: Push coverage analysis
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
run: cover -report codecov

# Install node (for npm) and use it to install eslint and stylelint dependencies.
- name: Use Node.js
uses: actions/setup-node@v2
# Install node (for npm).
- name: Set up node
uses: actions/setup-node@v3
with:
node-version: '16'

- name: Install Dependencies
run: npm ci

- name: Run typescript (client-side) tests
run: npm run test
73 changes: 44 additions & 29 deletions docker/webwork3.dockerfile
Original file line number Diff line number Diff line change
@@ -1,46 +1,61 @@
FROM ubuntu:20.04
FROM ubuntu:22.04

# the following are needed to make sure the timezone packages don't ask for your timezone.
ENV DEBIAN_FRONTEND noninteractive
ENV DEBCONF_NONINTERACTIVE_SEEN true
ENV DEBCONF_NOWARNINGS yes
ENV HARNESS_PERL_SWITCHES -MDevel::Cover

RUN apt-get update && \
apt-get install -qy --no-install-recommends --no-install-suggests \
build-essential=12.8ubuntu1 \
ca-certificates=20210119~20.04.1 \
cpanminus=1.7044-1 \
git=1:2.25.1-1ubuntu3.1 \
libarray-utils-perl=0.5-1 \
libclone-perl=0.43-2 \
libcrypt-ssleay-perl=0.73.06-1build3 \
libdata-dump-perl=1.23-1 \
libdatetime-format-strptime-perl=1.7600-1 \
libdbd-mysql-perl=4.050-3 \
libdbd-sqlite3-perl=1.64-1build1 \
libdbix-class-perl=0.082841-1 \
ca-certificates=20211016 \
cpanminus=1.7045-1 \
git=1:2.34.1-1ubuntu1.4 \
libarray-utils-perl=0.5-2 \
libcanary-stability-perl=2006-2 \
libcapture-tiny-perl=0.48-1 \
libclass-accessor-lite-perl=0.08-1.1 \
libclone-perl=0.45-1build3 \
libcommon-sense-perl=3.75-2build1 \
libcpanel-json-xs-perl=4.27-1build1 \
libcrypt-ssleay-perl=0.73.06-1build6 \
libdata-dump-perl=1.25-1 \
libdatetime-format-strptime-perl=1.7900-1 \
#libdbd-mysql-perl=4.050-5 \ # if desired to use a full database
libdbd-sqlite3-perl=1.70-3build1 \
libdbix-class-inflatecolumn-serializer-perl=0.09-1 \
libdbix-class-perl=0.082842-3 \
libdbix-dbschema-perl=0.45-1 \
libdevel-cover-perl=1.33-1build1 \
libexception-class-perl=1.44-1 \
libjson-perl=4.02000-2 \
libnet-ssleay-perl=1.88-2ubuntu1 \
libsql-translator-perl=1.60-1 \
libssl-dev=1.1.1f-1ubuntu2.5 \
libdevel-cover-perl=1.36-2build2 \
libc6-dev=2.35-0ubuntu3.1 \
libexception-class-perl=1.45-1 \
libextutils-config-perl=0.008-2 \
libextutils-helpers-perl=0.026-1 \
libextutils-installpaths-perl=0.012-1.1 \
libfurl-perl=3.14-2 \
libhttp-parser-xs-perl=0.17-2build1 \
libimporter-perl=0.026-1 \
libio-socket-ssl-perl=2.074-2 \
libjson-perl=4.04000-1 \
libjson-xs-perl=4.030-1build3 \
libmodule-build-tiny-perl=0.039-1.1 \
libmojolicious-perl=9.22+dfsg-1 \
libmojolicious-plugin-authentication-perl=1.37-1 \
libnet-ssleay-perl=1.92-1build2 \
libsql-translator-perl=1.62-1 \
libssl-dev=3.0.2-0ubuntu1.6 \
libtest-exception-perl=0.43-1 \
libtest-harness-perl=3.42-2 \
libtext-csv-perl=2.00-1 \
libtry-tiny-perl=0.30-1 \
libyaml-libyaml-perl=0.81+repack-1 \
# mariadb-server=1:10.3.31-0ubuntu0.20.04.1 \ # if desired to use a full database
openssl=1.1.1f-1ubuntu2.5 && \
libtext-csv-perl=2.01-1 \
libtry-tiny-perl=0.31-1 \
libtypes-serialiser-perl=1.01-1 \
libyaml-libyaml-perl=0.83+ds-1build1 \
make=4.3-4.1build1 \
#mariadb-server=1:10.6.7-2ubuntu1.1 \ # if desired to use a full database
openssl=3.0.2-0ubuntu1.6 && \
rm -rf /var/lib/apt/lists/* && \
cpanm --notest \
DBIx::Class::DynamicSubclass \
Mojolicious \
Mojolicious::Plugin::NotYAMLConfig \
Mojolicious::Plugin::DBIC \
Mojolicious::Plugin::Authentication \
Mojolicious::Plugin::NotYAMLConfig \
Devel::Cover::Report::Codecov

ENTRYPOINT ["/bin/bash"]
2 changes: 1 addition & 1 deletion lib/DB/Schema/Result/Attempt.pm
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Note: a problem should have only one of a library_id, problem_path or problem_po

__PACKAGE__->table('attempt');

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

__PACKAGE__->add_columns(
attempt_id => {
Expand Down
2 changes: 1 addition & 1 deletion lib/DB/Schema/Result/CourseSettings.pm
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ C<email>: a JSON object that stores email settings

__PACKAGE__->table('course_settings');

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

__PACKAGE__->add_columns(
course_settings_id => {
Expand Down
2 changes: 1 addition & 1 deletion lib/DB/Schema/Result/CourseUser.pm
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ C<showOldAnswers>: whether or not the user shows old answer (boolean)

__PACKAGE__->table('course_user');

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

__PACKAGE__->add_columns(
course_user_id => {
Expand Down
2 changes: 1 addition & 1 deletion lib/DB/Schema/Result/PoolProblem.pm
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Note: the C<params> can only have one of the two fields

__PACKAGE__->table('pool_problem');

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

__PACKAGE__->add_columns(
pool_problem_id => {
Expand Down
4 changes: 1 addition & 3 deletions lib/DB/Schema/Result/ProblemSet.pm
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,9 @@ L<DB::Schema::Result::ProblemSet::ReviewSet> which gives properties common to re
=cut

__PACKAGE__->load_components(qw/DynamicSubclass Core/);

__PACKAGE__->table('problem_set');

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

__PACKAGE__->add_columns(
set_id => {
Expand Down
2 changes: 1 addition & 1 deletion lib/DB/Schema/Result/SetProblem.pm
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Note: a problem should have only one of a library_id, problem_path or problem_po

__PACKAGE__->table('set_problem');

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

__PACKAGE__->add_columns(
set_problem_id => {
Expand Down
2 changes: 1 addition & 1 deletion lib/DB/Schema/Result/UserProblem.pm
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use base qw/DBIx::Class::Core DB::Validation/;

__PACKAGE__->table('user_problem');

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

__PACKAGE__->add_columns(
user_problem_id => {
Expand Down
2 changes: 1 addition & 1 deletion lib/DB/Schema/Result/UserSet.pm
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ types have different params fields.

__PACKAGE__->table('user_set');

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

__PACKAGE__->add_columns(
user_set_id => {
Expand Down
67 changes: 67 additions & 0 deletions lib/WeBWorK3.pm
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ sub loginRoutes ($app) {
return;
}

<<<<<<< Updated upstream
sub permissionRoutes ($authen_routes) {
$authen_routes->get('/roles')->to('Permission#getRoles');
$authen_routes->get('/ui-permissions')->to('Permission#getUIRoutePermissions');
Expand Down Expand Up @@ -225,6 +226,72 @@ sub settingsRoutes ($app, $course_routes) {
sub utilityRoutes ($app) {
$app->routes->post('/webwork3/api/client-logs')->requires(authenticated => 1)->to('Logger#clientLog');
=======
sub coursesRoutes ($self) {
my $course_routes =
$self->routes->any('/webwork3/api/courses')->requires(authenticated => 1)->to(controller => 'Course');
$course_routes->get('/')->to(action => 'getCourses');
$course_routes->get('/:course_id')->to(action => 'getCourse');
$course_routes->put('/:course_id')->to(action => 'updateCourse');
$course_routes->post('/')->to(action => 'addCourse');
$course_routes->delete('/:course_id')->to(action => 'deleteCourse');
return;
}
sub userRoutes ($self) {
my $user_routes = $self->routes->any('/webwork3/api/users')->requires(authenticated => 1)->to(controller => 'User');
$user_routes->get('/')->to(action => 'getGlobalUsers');
$user_routes->post('/')->to(action => 'addGlobalUser');
$user_routes->get('/:user')->to(action => 'getGlobalUser');
$user_routes->put('/:user_id')->to(action => 'updateGlobalUser');
$user_routes->delete('/:user_id')->to(action => 'deleteGlobalUser');
$user_routes->get('/:user_id/courses')->to(action => 'getUserCourses');
return;
}
sub courseUserRoutes ($self) {
my $course_user_routes = $self->routes->any('/webwork3/api/courses/:course_id/users')->requires(authenticated => 1)
->to(controller => 'User');
$course_user_routes->get('/')->to(action => 'getCourseUsers');
$course_user_routes->post('/')->to(action => 'addCourseUser');
$course_user_routes->get('/:user_id')->to(action => 'getCourseUser');
$course_user_routes->put('/:user_id')->to(action => 'updateCourseUser');
$course_user_routes->delete('/:user_id')->to(action => 'deleteCourseUser');
$self->routes->any('/webwork3/api/courses/:course_id/courseusers')->to('User#getMergedCourseUsers');
return;
}
sub problemSetRoutes ($self) {
$self->routes->get('/webwork3/api/sets')->to("ProblemSet#getProblemSets");
my $problem_set_routes =
$self->routes->any('/webwork3/api/courses/:course_id/sets')->requires(authenticated => 1)
->to(controller => 'ProblemSet');
$problem_set_routes->get('/')->to(action => 'getProblemSets');
$problem_set_routes->get('/:set_id')->to(action => 'getProblemSet');
$problem_set_routes->put('/:set_id')->to(action => 'updateProblemSet');
$problem_set_routes->post('/')->to(action => 'addProblemSet');
$problem_set_routes->delete('/:set_id')->to(action => 'deleteProblemSet');
return;
}
sub problemRoutes ($self) {
my $problem_routes =
$self->routes->any('/webwork3/api/courses/:course_id/sets/:set_id/problems')->requires(authenticated => 1)
->to(controller => 'Problem');
$problem_routes->post('/')->to(action => 'addProblem');
return;
}
sub settingsRoutes ($self) {
$self->routes->get('/webwork3/api/default_settings')->requires(authenticated => 1)
->to("Settings#getDefaultCourseSettings");
$self->routes->get('/webwork3/api/courses/:course_id/settings')->to("Settings#getCourseSettings");
return;
}
sub utilityRoutes ($self) {
$self->routes->post('/webwork3/api/client-logs')->requires(authenticated => 1)->to("Logger#clientLog");
>>>>>>> Stashed changes
return;
}
Expand Down
3 changes: 2 additions & 1 deletion t/db/001_courses.t
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use Test::More;
use Test::Exception;
use YAML::XS qw/LoadFile/;
use DateTime::Format::Strptime;
use Mojo::JSON qw/true false/;

use DB::Schema;

Expand Down Expand Up @@ -90,7 +91,7 @@ throws_ok {
# Add a course
my $new_course_params = {
course_name => 'Geometry',
visible => 1,
visible => true,
course_dates => {}
};

Expand Down
4 changes: 2 additions & 2 deletions t/db/004_course_users.t
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ my $user_rs = $schema->resultset('User');
# Get a list of users from the CSV file
my @students = loadCSV("$main::ww3_dir/t/db/sample_data/students.csv");
for my $student (@students) {
$student->{is_admin} = 0;
$student->{is_admin} = false;
$student->{course_user_params} = $student->{params};
delete $student->{params};
}
Expand Down Expand Up @@ -124,7 +124,7 @@ my $user_params = {
last_name => 'Quimby',
email => 'mayor_joe@springfield.gov',
student_id => '12345',
is_admin => 0
is_admin => false
};

my $course_user_params = {
Expand Down
Loading

0 comments on commit b8bcaa6

Please sign in to comment.