-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 69ebfa6
Showing
10 changed files
with
1,222 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,194 @@ | ||
name: CI | ||
on: [push] | ||
jobs: | ||
unit_tests: | ||
name: Run unit tests | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
koha-version: [master, stable, oldstable] | ||
steps: | ||
- uses: actions/checkout@v1 | ||
|
||
- name: Get Koha Version Branch Name | ||
id: koha-version | ||
uses: "bywatersolutions/github-action-koha-get-version-by-label@master" | ||
with: | ||
version-label: "${{ matrix.koha-version }}" | ||
|
||
- name: Check out Koha | ||
run: | | ||
cd .. | ||
git clone --branch ${{ steps.koha-version.outputs.current-branch-name }} --single-branch --depth 1 git://git.koha-community.org/koha.git kohaclone | ||
- name: Export additional variables needed by koha-testing-docker | ||
run: | | ||
cd .. | ||
pwd | ||
ls -alh | ||
IFS='/' read -r -a parts <<< "$GITHUB_REPOSITORY" | ||
export GITHUB_REPO="${parts[1]}" | ||
export ROOT_DIR="$(pwd)" | ||
export LOCAL_USER_ID="$(id -u)" # Needed for koha-testing-docker | ||
export SYNC_REPO="$ROOT_DIR/kohaclone" | ||
export KOHA_INTRANET_URL="http://127.0.0.1:8081" | ||
export KOHA_MARC_FLAVOUR="marc21" | ||
echo ::set-env name=GITHUB_REPO::$GITHUB_REPO | ||
echo ::set-env name=ROOT_DIR::$ROOT_DIR | ||
echo ::set-env name=LOCAL_USER_ID::$LOCAL_USER_ID | ||
echo ::set-env name=SYNC_REPO::$SYNC_REPO | ||
echo ::set-env name=KOHA_INTRANET_URL::$KOHA_INTRANET_URL | ||
echo ::set-env name=KOHA_MARC_FLAVOUR::$KOHA_MARC_FLAVOUR | ||
echo ::set-env name=RUN_TESTS_AND_EXIT::no | ||
echo ::set-env name=KOHA_IMAGE::master | ||
echo "GITHUB REPO: $GITHUB_REPO" | ||
echo "ROOT DIR: $ROOT_DIR" | ||
echo "SYNC_REPO: $SYNC_REPO" | ||
ls -alh $SYNC_REPO | ||
- name: Set up koha-testing-docker | ||
run: | | ||
sudo sysctl -w vm.max_map_count=262144 | ||
wget -O docker-compose.yml https://gitlab.com/koha-community/koha-testing-docker/raw/master/docker-compose.yml | ||
mkdir -p env | ||
wget -O env/defaults.env https://gitlab.com/koha-community/koha-testing-docker/raw/master/env/defaults.env | ||
cp env/defaults.env .env | ||
docker-compose pull | ||
# - name: Setup Debug Session | ||
# uses: csexton/debugger-action@master | ||
|
||
- name: Run tests | ||
run: | | ||
pwd | ||
ls -alh | ||
docker-compose -f docker-compose.yml -p koha up --detach | ||
cd .. | ||
pwd | ||
ls -alh | ||
echo "SLEEPING 3 MINUTES" | ||
sleep 60 | ||
echo "1 MINUTE DONE" | ||
sleep 60 | ||
echo "2 MINUTES DONE" | ||
sleep 60 | ||
echo "3 MINUTES DONE" | ||
echo "WAKING UP" | ||
docker cp $GITHUB_REPO/. koha_koha_1:/var/lib/koha/kohadev/plugins | ||
docker exec koha_koha_1 bash -c 'prove /var/lib/koha/kohadev/plugins/t' | ||
- name: Post test cleanup | ||
run: | | ||
docker-compose down | ||
docker rm -f $(docker ps -a -f "name=koha_" -q) | ||
docker volume prune -f | ||
docker image prune -f | ||
rm docker-compose.yml | ||
rm -rf env .env | ||
release: | ||
name: Build & Release | ||
runs-on: ubuntu-latest | ||
needs: unit_tests | ||
strategy: | ||
fail-fast: false | ||
steps: | ||
- uses: actions/checkout@v1 | ||
|
||
- name: Parse out and store the GitHub repository name | ||
id: myvars | ||
run: | | ||
IFS='/' read -r -a parts <<< "$GITHUB_REPOSITORY" | ||
GITHUB_REPO="${parts[1]}" | ||
echo ::set-output name=github_repo::$GITHUB_REPO | ||
echo "GITHUB REPO: $GITHUB_REPO" | ||
- name: Get Previous tag | ||
id: previoustag | ||
uses: "WyriHaximus/github-action-get-previous-tag@master" | ||
env: | ||
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" | ||
|
||
- name: Get next minor version | ||
id: semvers | ||
uses: "WyriHaximus/github-action-next-semvers@master" | ||
with: | ||
version: ${{ steps.previoustag.outputs.tag }} | ||
|
||
- name: Get Koha Version Branch Name | ||
id: koha-version-oldstable | ||
uses: "bywatersolutions/github-action-koha-get-version-by-label@master" | ||
with: | ||
version-label: "oldstable" | ||
|
||
- name: Print minimum version | ||
run: | | ||
echo "Current oldstable version: ${{ steps.koha-version-oldstable.outputs.version-major-minor }}" | ||
- name: Build Koha Plugin kpz artifact | ||
id: kpz | ||
uses: "bywatersolutions/github-action-koha-plugin-create-kpz@master" | ||
with: | ||
release-version: ${{ steps.semvers.outputs.v_patch }} | ||
release-name: ${{ steps.myvars.outputs.GITHUB_REPO }} | ||
minimum-version: ${{ steps.koha-version-oldstable.outputs.version-major-minor }} | ||
|
||
- name: See if kpz was created | ||
run: | | ||
echo "FILENAME: ${{ steps.kpz.outputs.filename }}" | ||
ls -alh | ||
- name: Create Release | ||
id: create_release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token | ||
with: | ||
tag_name: ${{ steps.semvers.outputs.v_patch }} | ||
release_name: Release ${{ steps.semvers.outputs.v_patch }} | ||
draft: false | ||
prerelease: false | ||
|
||
- name: Upload Release Asset kpz | ||
id: upload-release-asset-kpz | ||
uses: actions/[email protected] | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: ./${{ steps.kpz.outputs.filename }} | ||
asset_name: ${{ steps.kpz.outputs.filename }} | ||
asset_content_type: application/kpz | ||
|
||
- name: Upload Release Asset PLUGIN.yml | ||
id: upload-release-asset-meta | ||
uses: actions/[email protected] | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: ./PLUGIN.yml | ||
asset_name: PLUGIN.yml | ||
asset_content_type: text/yaml | ||
|
||
- name: Upload Release Asset README.md | ||
id: upload-release-asset-readme | ||
uses: actions/[email protected] | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: ./README.md | ||
asset_name: README.md | ||
asset_content_type: text/markdown | ||
|
||
- name: Upload Release Asset CHANGELOG.md | ||
id: upload-release-asset-changelog | ||
uses: actions/[email protected] | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: ./CHANGELOG.md | ||
asset_name: CHANGELOG.md | ||
asset_content_type: text/markdown |
This file contains 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,9 @@ | ||
# Changelog | ||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), | ||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
||
## [0.0.2] - 2020-05-13 | ||
### Added | ||
This plugin, initial commit ;) |
This file contains 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,104 @@ | ||
package Koha::Plugin::Com::ByWaterSolutions::TwilioVoice; | ||
|
||
use Modern::Perl; | ||
|
||
use base qw(Koha::Plugins::Base); | ||
|
||
use C4::Context; | ||
use C4::Auth; | ||
|
||
## Here we set our plugin version | ||
our $VERSION = "{VERSION}"; | ||
our $MINIMUM_VERSION = "{MINIMUM_VERSION}"; | ||
|
||
## Here is our metadata, some keys are required, some are optional | ||
our $metadata = { | ||
name => 'Twilio Voice Plugin', | ||
author => 'Kyle M Hall', | ||
date_authored => '2020-05-13', | ||
date_updated => "1900-01-01", | ||
minimum_version => $MINIMUM_VERSION, | ||
maximum_version => undef, | ||
version => $VERSION, | ||
description => 'This plugin enables sending of phone message to patrons via Twilio.', | ||
}; | ||
|
||
sub new { | ||
my ( $class, $args ) = @_; | ||
|
||
## We need to add our metadata here so our base class can access it | ||
$args->{'metadata'} = $metadata; | ||
$args->{'metadata'}->{'class'} = $class; | ||
|
||
## Here, we call the 'new' method for our base class | ||
## This runs some additional magic and checking | ||
## and returns our actual $self | ||
my $self = $class->SUPER::new($args); | ||
|
||
return $self; | ||
} | ||
|
||
sub configure { | ||
my ( $self, $args ) = @_; | ||
my $cgi = $self->{'cgi'}; | ||
|
||
unless ( $cgi->param('save') ) { | ||
my $template = $self->get_template({ file => 'configure.tt' }); | ||
|
||
## Grab the values we already have for our settings, if any exist | ||
$template->param( | ||
enable_opac_payments => $self->retrieve_data('enable_opac_payments'), | ||
foo => $self->retrieve_data('foo'), | ||
bar => $self->retrieve_data('bar'), | ||
last_upgraded => $self->retrieve_data('last_upgraded'), | ||
); | ||
|
||
$self->output_html( $template->output() ); | ||
} | ||
else { | ||
$self->store_data( | ||
{ | ||
enable_opac_payments => $cgi->param('enable_opac_payments'), | ||
foo => $cgi->param('foo'), | ||
bar => $cgi->param('bar'), | ||
last_configured_by => C4::Context->userenv->{'number'}, | ||
} | ||
); | ||
$self->go_home(); | ||
} | ||
} | ||
|
||
sub install() { | ||
my ( $self, $args ) = @_; | ||
|
||
return 1; | ||
} | ||
|
||
sub upgrade { | ||
my ( $self, $args ) = @_; | ||
|
||
return 1; | ||
} | ||
|
||
sub uninstall() { | ||
my ( $self, $args ) = @_; | ||
|
||
return 1; | ||
} | ||
|
||
sub api_routes { | ||
my ( $self, $args ) = @_; | ||
|
||
my $spec_str = $self->mbf_read('openapi.json'); | ||
my $spec = decode_json($spec_str); | ||
|
||
return $spec; | ||
} | ||
|
||
sub api_namespace { | ||
my ( $self ) = @_; | ||
|
||
return 'twiliovoice'; | ||
} | ||
|
||
1; |
43 changes: 43 additions & 0 deletions
43
Koha/Plugin/Com/ByWaterSolutions/TwilioVoice/BotherPatronController.pm
This file contains 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 @@ | ||
package Koha::Plugin::Com::ByWaterSolutions::TwilioVoice::BotherPatronController; | ||
|
||
# This file is part of Koha. | ||
# | ||
# Koha is free software; you can redistribute it and/or modify it under the | ||
# terms of the GNU General Public License as published by the Free Software | ||
# Foundation; either version 3 of the License, or (at your option) any later | ||
# version. | ||
# | ||
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY | ||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR | ||
# A PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License along | ||
# with Koha; if not, write to the Free Software Foundation, Inc., | ||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
|
||
use Modern::Perl; | ||
|
||
use Mojo::Base 'Mojolicious::Controller'; | ||
|
||
=head1 API | ||
=head2 Class Methods | ||
=head3 Method that bothers the patron, with no side effects | ||
=cut | ||
|
||
sub bother { | ||
my $c = shift->openapi->valid_input or return; | ||
|
||
my $patron_id = $c->validation->param('patron_id'); | ||
my $patron = Koha::Patrons->find($patron_id); | ||
|
||
unless ($patron) { | ||
return $c->render( status => 404, openapi => { error => "Patron not found." } ); | ||
} | ||
|
||
return $c->render( status => 200, openapi => { bothered => Mojo::JSON->true } ); | ||
} | ||
|
||
1; |
This file contains 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,9 @@ | ||
name: Twilio Voice Plugin | ||
author: Kyle M Hall | ||
date_authored: 2020-05-13 | ||
date_updated: 1900-01-01 | ||
minimum_version: {MINIMUM_VERSION} | ||
maximum_version: | ||
version: {VERSION} | ||
description: This plugin enables sending of phone message to patrons via Twilio. | ||
module: Koha::Plugin::Com::ByWaterSolutions::TwilioVoice |
Oops, something went wrong.