Skip to content
Open
5 changes: 3 additions & 2 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,23 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
end

if ENV['BUILD'] == '1'
config.vm.box = "debian/bullseye64"
config.vm.box = "debian/bookworm64"
config.vm.provision "install", :type => "ansible" do |ansible|
# ansible.verbose = "vvvv"
ansible.playbook = "ansible/vagrant.yml"
end
config.vm.provision "strip", :type => "shell", :path => "reduce_box_size.sh"
else
config.vm.box = "tatoeba/tatovm"
config.vm.box_version = "0.2.1"
config.vm.box_version = "0.3.0"
config.vm.provision "install",
:type => "shell",
:privileged => false,
:path => "tools/codeinit.py",
:args => ["/home/vagrant/Tatoeba"]

config.vm.provision "shell", inline: <<-SHELL
systemctl start manticore
apt-get update && apt-get -y upgrade && apt-get -y dist-upgrade
SHELL

Expand Down
36 changes: 34 additions & 2 deletions ansible/roles/common/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,39 @@
state: latest
force: yes

- name: Install packages needed for development
- name: Check if Transifex client is installed
when: deploy_for == 'dev'
stat:
path: /usr/local/bin/tx
register: tx

- name: Download Transifex client
when:
- deploy_for == 'dev'
- not tx.stat.exists
get_url:
url: https://github.com/transifex/cli/releases/download/v1.6.17/tx-linux-amd64.tar.gz
dest: /tmp/tx-linux-amd64.tar.gz

- name: Uncompress Transifex client
when:
- deploy_for == 'dev'
- not tx.stat.exists
unarchive:
src: /tmp/tx-linux-amd64.tar.gz
dest: /usr/local/bin/
include: tx
remote_src: yes

- name: Remove Transifex archive
when:
- deploy_for == 'dev'
- not tx.stat.exists
file:
path: /tmp/tx-linux-amd64.tar.gz
state: absent

- name: Install other packages needed for development
apt:
name: ['gettext', 'transifex-client', 'python3-jinja2', 'python3-yaml']
name: ['gettext', 'python3-jinja2', 'python3-yaml']
when: deploy_for == 'dev'
28 changes: 28 additions & 0 deletions ansible/roles/common_debian/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
---

- name: Temporarily stop unattended upgrades
systemd_service:
name: unattended-upgrades
state: stopped

- name: Copy sources.list for apt
template:
src: sources.list
Expand All @@ -15,6 +20,29 @@
update_cache: yes
when: result is changed

- name: Update all packages
apt:
upgrade: yes

- name: List installed kernels
shell: ls -1 /lib/modules | sort -rV
register: installed_kernels

- name: Reboot unless running latest kernel
reboot:
when: installed_kernels.stdout_lines | length > 1 and installed_kernels.stdout_lines[0] != ansible_facts['kernel']

- name: List unused kernels
shell: ls -1 /lib/modules | grep -v "^$(uname -r)$" | sed 's,^,linux-image-,'
register: unused_kernels

- name: Remove unused kernels
apt:
name: "{{unused_kernels.stdout_lines}}"
state: absent
purge: true
when: unused_kernels.stdout_lines | length > 0

- name: Add extra PATH directories
copy:
dest: /etc/profile.d/custom-path.sh
Expand Down
12 changes: 6 additions & 6 deletions ansible/roles/common_debian/templates/sources.list
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
deb http://{{mirror}}/debian {{release}} main contrib non-free
deb-src http://{{mirror}}/debian {{release}} main contrib non-free
deb http://{{mirror}}/debian {{release}} main contrib
deb-src http://{{mirror}}/debian {{release}} main contrib

deb https://{{security_mirror}}/debian-security {{release}}-security/updates main contrib non-free
deb-src https://{{security_mirror}}/debian-security {{release}}-security/updates main contrib non-free
deb https://{{security_mirror}}/debian-security {{release}}-security/updates main contrib
deb-src https://{{security_mirror}}/debian-security {{release}}-security/updates main contrib

# {{release}}-updates, previously known as 'volatile'
deb http://{{mirror}}/debian {{release}}-updates main contrib non-free
deb-src http://{{mirror}}/debian {{release}}-updates main contrib non-free
deb http://{{mirror}}/debian {{release}}-updates main contrib
deb-src http://{{mirror}}/debian {{release}}-updates main contrib

# {{release}}-backports
deb http://{{mirror}}/debian {{release}}-backports main
6 changes: 1 addition & 5 deletions ansible/roles/setup_manticore/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@

- name: Install Manticore package
apt:
deb: https://github.com/manticoresoftware/manticoresearch/releases/download/3.3.0/manticore_3.3.0-200204-01fc8ad1-release.buster_amd64-bin.deb

- name: Install Manticore language packs
apt:
deb: https://repo.manticoresearch.com/repository/manticoresearch_bullseye/dists/bullseye/main/binary-amd64/manticore-language-packs_1.0.13-250708-1e9c2cd_all.deb
deb: https://repo.manticoresearch.com/repository/manticoresearch_bookworm/dists/bookworm/main/binary-amd64/manticore_25.0.0-26032712-ce3c27828_amd64.deb

- name: Work around bug that prevents enabling Manticore
file:
Expand Down
31 changes: 26 additions & 5 deletions ansible/roles/setup_php/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,36 @@
---

- name: Add Surý's GPG key
get_url:
url: https://packages.sury.org/php/apt.gpg
dest: /etc/apt/keyrings/deb.sury.org-php.gpg
mode: 0644

- name: Add Surý's PHP repository
template:
src: php.list
dest: /etc/apt/sources.list.d/php.list
owner: root
group: root
mode: 0644
vars:
signfile: /etc/apt/keyrings/deb.sury.org-php.gpg

- name: Install php
apt:
name: ['php-fpm', 'php-cli',
'php-mysql', 'php-intl', 'php-curl', 'php-memcached', 'php-imagick',
'php-xml', 'php-mbstring', 'php-zip', 'php-sqlite3',
'memcached', 'composer']
name: ['php7.4-fpm', 'php7.4-cli',
'php7.4-mysql', 'php7.4-intl', 'php7.4-curl', 'php7.4-memcached', 'php7.4-imagick',
'php7.4-xml', 'php7.4-mbstring', 'php7.4-zip', 'php7.4-sqlite3',
'memcached']
update_cache: yes
cache_valid_time: 36000
state: latest

- name: Install composer
get_url:
url: https://getcomposer.org/download/2.9.7/composer.phar
dest: /usr/local/bin/composer
mode: 0755

- name: Remove default fpm pool
file:
path: /etc/php/7.4/fpm/pool.d/www.conf
Expand Down
1 change: 1 addition & 0 deletions ansible/roles/setup_php/templates/php.list
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
deb [signed-by={{signfile}}] https://packages.sury.org/php/ {{release}} main
16 changes: 14 additions & 2 deletions ansible/roles/setup_sinoparserd/tasks/install_sinoparserd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,22 @@

- name: Install dependencies for sinoparserd
apt:
name: ['make', 'cmake', 'g++',
'libevent-dev', 'libexpat1-dev', 'libgmm++-dev']
name: ['libevent-2.1-7', 'libexpat1']
state: present

- name: Fetch sinoparserd source
git: repo=https://github.com/Tatoeba/sinoparserd.git dest=/tmp/sinoparserd force=yes

- name: Save packages selection
shell: dpkg --get-selections > /tmp/sinoparserd/all_selections
args:
creates: /tmp/sinoparserd/all_selections

- name: Install build dependencies for sinoparserd
apt:
name: ['make', 'cmake', 'g++', 'libevent-dev', 'libexpat1-dev', 'libgmm++-dev']
state: present

- name: Fix to import the correct file in Index.h
replace:
path: /tmp/sinoparserd/src/Index.h
Expand Down Expand Up @@ -56,6 +65,9 @@
state: started
enabled: yes

- name: Uninstall build dependencies
shell: dpkg --clear-selections && dpkg --set-selections < /tmp/sinoparserd/all_selections && apt-get -y dselect-upgrade

- name: Remove temporary files
file:
path: /tmp/sinoparserd
Expand Down
44 changes: 22 additions & 22 deletions ansible/tatoeba.tasks.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,4 @@
---
- name: Install and setup nginx
tags: nginx, lemp
import_role:
name: setup_nginx

- name: Install and setup PHP
tags: php, lemp
import_role:
name: setup_php

- name: Install and setup MySQL
tags: mysql, lemp
import_role:
name: setup_mysql

- name: Install and setup Tatoeba's database
tags: tatoeba, database
import_role:
name: setup_database
vars:
import_csv: 'no'

- name: Install and setup Tatomecab
tags: tatomecab, external_tools
import_role:
Expand All @@ -40,13 +18,35 @@
repo: https://github.com/Tatoeba/Tatodetect
force_install: no

- name: Install and setup nginx
tags: nginx, lemp
import_role:
name: setup_nginx

- name: Install and setup Tatowiki
tags: tatowiki, external_tools
import_tasks: install.yml
vars:
repo: https://github.com/Tatoeba/tatowiki
force_install: no

- name: Install and setup PHP
tags: php, lemp
import_role:
name: setup_php

- name: Install and setup MySQL
tags: mysql, lemp
import_role:
name: setup_mysql

- name: Install and setup Tatoeba's database
tags: tatoeba, database
import_role:
name: setup_database
vars:
import_csv: 'no'

- name: Install and setup search engine
tags: manticore
import_role:
Expand Down
4 changes: 2 additions & 2 deletions tests/TestCase/View/Helper/AnnouncementHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,14 @@ public function maintenanceProvider() {
// value for Announcement in app_config.php
[ 'maintenance' => [ 'start' => '2020-05-30 02:00 UTC' ] ],
// confirm this text is in the maintenance message
'on May 30, 2020 at 2:00 AM UTC, which is in 2 days',
'on May 30, 2020 at 2:00AM UTC, which is in 2 days',
// confirm whether of not maintenance is considered "imminent"
false,
],
'maintenance in 1 day' => [
'2020-05-29 02:00:00 UTC',
[ 'maintenance' => [ 'start' => '2020-05-30 02:00 UTC' ] ],
'on May 30, 2020 at 2:00 AM UTC, which is in 1 day',
'on May 30, 2020 at 2:00AM UTC, which is in 1 day',
false,
],
'maintenance in 2 hours' => [
Expand Down
14 changes: 7 additions & 7 deletions tests/TestCase/View/Helper/DateHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,19 +98,19 @@ public function getDateLabelContentProvider() {
'created within 30 days eng' =>
['{createdDate}, edited {modifiedDate}', '2018-09-29 09:12:34', '2018-09-29 09:12:34', false, 'en', '25&nbsp;days ago'],
'created within 30 days tooltip eng' =>
['{createdDate}, edited {modifiedDate}', '2018-09-09 09:12:34', '2018-09-09 09:12:34', true, 'en', 'September 9, 2018 at 9:12 AM'],
['{createdDate}, edited {modifiedDate}', '2018-09-09 09:12:34', '2018-09-09 09:12:34', true, 'en', 'September 9, 2018 at 9:12AM'],
'created and modified within 30 days eng' =>
['{createdDate}, edited {modifiedDate}', '2018-09-29 09:12:34', '2018-10-10 01:23:45', false, 'en', '25&nbsp;days ago, edited 14&nbsp;days ago'],
'created and modified within 30 days tooltip eng' =>
['{createdDate}, edited {modifiedDate}', '2018-09-09 09:12:34', '2018-10-10 01:23:45', true, 'en', 'September 9, 2018 at 9:12 AM, edited October 10, 2018 at 1:23 AM'],
['{createdDate}, edited {modifiedDate}', '2018-09-09 09:12:34', '2018-10-10 01:23:45', true, 'en', 'September 9, 2018 at 9:12AM, edited October 10, 2018 at 1:23AM'],
'created eng' =>
['{createdDate}, edited {modifiedDate}', '2017-09-29 09:12:34', '2017-09-29 09:12:34', false, 'en', 'September 29, 2017'],
'created tooltip eng' =>
['{createdDate}, edited {modifiedDate}', '2017-09-09 09:12:34', '2017-09-09 09:12:34', true, 'en', 'September 9, 2017 at 9:12 AM'],
['{createdDate}, edited {modifiedDate}', '2017-09-09 09:12:34', '2017-09-09 09:12:34', true, 'en', 'September 9, 2017 at 9:12AM'],
'created and modified eng' =>
['{createdDate}, edited {modifiedDate}', '2017-09-29 09:12:34', '2017-10-10 01:23:45', false, 'en', 'September 29, 2017, edited October 10, 2017'],
'created and modified tooltip eng' =>
['{createdDate}, edited {modifiedDate}', '2018-02-09 09:12:34', '2018-02-10 01:23:45', true, 'en', 'February 9, 2018 at 9:12 AM, edited February 10, 2018 at 1:23 AM'],
['{createdDate}, edited {modifiedDate}', '2018-02-09 09:12:34', '2018-02-10 01:23:45', true, 'en', 'February 9, 2018 at 9:12AM, edited February 10, 2018 at 1:23AM'],
'empty date eng' =>
['{createdDate}, edited {modifiedDate}', '0000-00-00 00:00:00', '0000-00-00 00:00:00', false, 'en', 'date unknown'],
'empty date tooltip eng' =>
Expand All @@ -135,10 +135,10 @@ public function niceContentProvider() {
'null' => [null, 'date unknown'],
'0000-00-00 00:00:00' => ['0000-00-00 00:00:00', 'date unknown'],
'CakePHP Time instance' =>
[new Time('1987-06-05 23:45:19'), 'June 5, 1987 at 11:45 PM'],
[new Time('1987-06-05 23:45:19'), 'June 5, 1987 at 11:45PM'],
'CakePHP FrozenTime instance' =>
[new FrozenTime('1983-06-05 23:45:19'), 'June 5, 1983 at 11:45:19 PM UTC'],
'string' => ['2000-12-07 01:23:45', 'December 7, 2000 at 1:23 AM']
[new FrozenTime('1983-06-05 23:45:19'), 'June 5, 1983 at 11:45:19PM UTC'],
'string' => ['2000-12-07 01:23:45', 'December 7, 2000 at 1:23AM']
];
}

Expand Down