Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: 2
jobs:
build:
docker:
- image: ubuntu:16.04
- image: ubuntu:24.04
steps:
- checkout
- run:
Expand All @@ -19,25 +19,25 @@ jobs:
command: puppet apply --modulepath=/buttonmen/deploy/vagrant/modules /buttonmen/deploy/circleci/manifests/init.pp
- run:
name: Audit line termination of all files in the tree to match Button Men standard
command: python deploy/circleci/audit_newlines.py
command: python3 deploy/circleci/audit_newlines.py
- run:
name: Audit layout of .php files in the tree to match Button Men standard
command: php ./deploy/circleci/audit_php_files.php .
- run:
name: Audit test coverage of .js files in the tree to match Button Men standard
command: python ./deploy/circleci/audit_js_unit_test_coverage.py
command: python3 ./deploy/circleci/audit_js_unit_test_coverage.py
- run:
name: Run grunt JS lint tests
command: sh ./util/grunt/circleci-grunt.sh
- run:
name: Generate checkstyle.xml using PHP_CodeSniffer
command: php /etc/php/7.0/deploy-includes/phpcs.phar --report=checkstyle --report-file=./build/logs/checkstyle.xml --standard=./deploy/circleci/checkstyle/buttonmen.xml ./src/api ./src/engine
command: php /etc/php/8.3/deploy-includes/phpcs.phar --report=checkstyle --report-file=./build/logs/checkstyle.xml --standard=./deploy/circleci/checkstyle/buttonmen.xml ./src/api ./src/engine
- run:
name: Test consistency of mysql database update files
command: /usr/local/bin/branch_database_rebuild_test
- run:
name: Run unit tests using PHPUnit and generates junit.xml and clover.xml
command: phpunit --bootstrap ./deploy/circleci/phpunit_bootstrap.php --log-junit build/logs/junit.xml --coverage-clover build/logs/clover.xml --debug test/
command: phpunit --dont-report-useless-tests --bootstrap ./deploy/circleci/phpunit_bootstrap.php --log-junit build/logs/junit.xml --coverage-clover build/logs/clover.xml --debug test/
- run:
name: Install dummy API files created by PHPUnit into test webserver
command: rsync -av src/api/dummy_data/ /var/www/api/dummy_data/
Expand All @@ -46,7 +46,9 @@ jobs:
command: bash ./deploy/circleci/verify_dummy_responder_files.sh src/api/dummy_data/ /var/www/api/dummy_data/
- run:
name: Run QUnit tests
command: /usr/bin/xvfb-run /usr/bin/phantomjs --web-security=false /usr/local/etc/run-jscover-qunit.js http://localhost/test-ui/phantom-index.html
command: /usr/bin/xvfb-run /usr/local/bin/phantomjs --web-security=false /usr/local/etc/run-jscover-qunit.js http://localhost/test-ui/phantom-index.html
environment:
OPENSSL_CONF: /dev/null
- run:
name: Run python2 client unit tests
command: /usr/local/bin/run_buttonmen_python_tests
Expand All @@ -64,13 +66,13 @@ jobs:
command: pdepend --jdepend-xml=./build/logs/jdepend.xml --jdepend-chart=./build/pdepend/dependencies.svg --overview-pyramid=build/pdepend/overview-pyramid.svg ./src
- run:
name: Generate pmd.xml using PHPMD
command: php /etc/php/7.0/deploy-includes/phpmd.phar ./src xml ./deploy/circleci/pmd/buttonmen.xml --reportfile ./build/logs/pmd.xml
command: php /etc/php/8.3/deploy-includes/phpmd.phar ./src xml ./deploy/circleci/pmd/buttonmen.xml --reportfile ./build/logs/pmd.xml
- run:
name: Generate phploc.csv
command: /usr/bin/phploc --log-csv ./build/logs/phploc.csv ./src
- run:
name: Aggregate tool output with PHP_CodeBrowser
command: php /etc/php/7.0/deploy-includes/phpcb.phar --log ./build/logs --source ./src --output ./build/code-browser
command: php /etc/php/8.3/deploy-includes/phpcb.phar --log ./build/logs --source ./src --output ./build/code-browser
- store_artifacts:
path: build

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM --platform=linux/amd64 ubuntu:16.04
FROM --platform=linux/amd64 ubuntu:24.04
RUN mkdir /buttonmen
WORKDIR /buttonmen
COPY . .
Expand Down
12 changes: 6 additions & 6 deletions deploy/circleci/audit_js_unit_test_coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ def find_test_files():
return testpairs

def check_test_file_functions(modname, srcpath, testpath):
function_name_re = re.compile('^(%s\.\S+) = function\(' % modname)
test_name_re = re.compile('^(test|asyncTest)\("test_([^"]+)"')
function_name_re = re.compile('^(%s.[^ \t\n\r\f\v]+) = function[(]' % modname)
test_name_re = re.compile('^(test|asyncTest)[(]"test_([^"]+)"')
Comment on lines -34 to +35
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drive-by comment: i could not tell you why python 3.12 has decided it's so much cleaner to use [^ \t\n\r\f\v] than \S (and [(] than \(). This seems like a mistake someone is going to fix at some point, but the SyntaxWarnings are pretty distracting, and we don't have to touch this code all that often, so i just decided to go with what python 3.12 told me to do.


# Populate the list of functions we expect will be tested
functions_missing = ['%s_is_loaded' % modname, ]
Expand Down Expand Up @@ -82,15 +82,15 @@ def check_index_file_inclusions(testpairs):
% (JSTESTINDEX, file_included, includes_missing[file_included]))

testpairs = find_test_files()
print "Looking for JavaScript unit tests to match Button Men spec: %s" % testpairs
print("Looking for JavaScript unit tests to match Button Men spec: %s" % testpairs)
for [modname, srcpath, testpath] in testpairs:
check_test_file_functions(modname, srcpath, testpath)
check_index_file_inclusions(testpairs)

if len(errors) > 0:
print "JavaScript code coverage problems were found:"
print("JavaScript code coverage problems were found:")
for errtext in errors:
print " " + errtext
print(" " + errtext)
sys.exit(1)
print "OK"
print("OK")
sys.exit(0)
10 changes: 5 additions & 5 deletions deploy/circleci/audit_newlines.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
##### A utility to verify that all code files use Unix-style newlines

import os
Expand Down Expand Up @@ -40,11 +40,11 @@ def find_files(dirname):
elif os.path.isfile(itempath):
files.append(itempath)
else:
raise ValueError, "%s is neither a directory nor a file" % itempath
raise ValueError("%s is neither a directory nor a file" % itempath)
return files

def file_has_unix_endings(filepath):
f = open(filepath, 'U')
f = open(filepath)
f.readlines()
if f.newlines == '\n':
return True
Expand All @@ -55,7 +55,7 @@ def file_has_unix_endings(filepath):
if not file_has_unix_endings(filepath):
badfiles.append(filepath)
if len(badfiles) > 0:
print "Some files lack Unix-style line termination: %s" % badfiles
print("Some files lack Unix-style line termination: %s" % badfiles)
sys.exit(1)
print "OK"
print("OK")
sys.exit(0)
4 changes: 1 addition & 3 deletions deploy/circleci/manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
$buttonmen_site_type = "production"
$puppet_timestamp = generate('/bin/date', '+%s')

$puppet_apache_sitesdir = "sites-enabled"

# Generic node configuration
include "apt::client"
include "ntp::client"
Expand All @@ -21,7 +19,7 @@
include "apache::server::circleci"
include "php::type::circleci"
include "mysql::server"
include "buttonmen::python-api-client"
include "buttonmen::python_api_client"
include "buttonmen::server"
include "javascript::type::circleci"
}
2 changes: 1 addition & 1 deletion deploy/docker/startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -e
set -x

# System services
/etc/init.d/rsyslog start
/usr/sbin/rsyslogd
/etc/init.d/cron start
/etc/init.d/ssh start
/etc/init.d/postfix start
Expand Down
2 changes: 1 addition & 1 deletion deploy/docker/startup_replay.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -e
set -x

# System services
/etc/init.d/rsyslog start
/usr/sbin/rsyslogd
/etc/init.d/cron start
/etc/init.d/ssh start
/etc/init.d/postfix start
Expand Down
4 changes: 3 additions & 1 deletion deploy/vagrant/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
# Exit if anything goes wrong
set -e

# Output execution details
set -x

# Make sure puppet is installed
if which puppet > /dev/null ; then
echo "Puppet is already installed"
else
apt-get update
apt-get -y install puppet
fi

22 changes: 3 additions & 19 deletions deploy/vagrant/manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -19,35 +19,19 @@

$puppet_timestamp = generate('/bin/date', '+%s')

case "$operatingsystemrelease" {
"14.04", "16.04": {
$puppet_apache_sitesdir = "sites-enabled"
}
default: {
$puppet_apache_sitesdir = "conf.d"
}
}

# Generic node configuration
include "apt::client"
include "ntp::client"
include "postfix::base"
include "syslog::base"
include "user::buttonmen-devs"
include "sudo::buttonmen-devs"
include "user::buttonmen_devs"
include "sudo::buttonmen_devs"
include "fqdn::base"

# Node configuration needed for the buttonmen server
include "apache::server::vagrant"
include "php::base"
include "mysql::server"
include "buttonmen::python-api-client"
include "buttonmen::python_api_client"
include "buttonmen::server"

# location-specific configuration
case "${ec2_services_partition}" {
"aws": {
include "cloudwatch::buttonmen-site"
}
}
}
20 changes: 10 additions & 10 deletions deploy/vagrant/modules/apache/manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
}

# Use mod_pagespeed to handle caching/refreshing of pages
include "apache::server::feature::mod-pagespeed"
include "apache::server::feature::mod_pagespeed"

# Monitor the error log
include "apache::server::feature::monitor-logs"
include "apache::server::feature::monitor_logs"

# Install letsencrypt
include "apache::server::feature::letsencrypt"
Expand Down Expand Up @@ -48,7 +48,7 @@
include "apache::server::vagrant"
}

class apache::server::feature::monitor-logs {
class apache::server::feature::monitor_logs {

# Install the logtail package
package {
Expand All @@ -59,13 +59,13 @@
# Setup a directory for logtail2 to use for its offset files
"/var/spool/logtail":
ensure => directory,
mode => 0755;
mode => "0755";

# Install a script to use for monitoring logs
"/usr/local/sbin/monitor_apache_logs":
ensure => file,
content => template("apache/monitor_apache_logs.erb"),
mode => 0555;
mode => "0555";
}

# Run the log-monitoring script from a nightly cron job
Expand All @@ -84,10 +84,10 @@
}
}

class apache::server::feature::mod-pagespeed {
class apache::server::feature::mod_pagespeed {
exec {
"apache_mod_pagespeed_pkg_download":
command => "/usr/bin/wget --no-verbose -O /usr/local/src/mod-pagespeed-stable_current.deb https://dl-ssl.google.com/dl/linux/direct/mod-pagespeed-stable_current_${architecture}.deb",
command => "/usr/bin/wget --no-verbose -O /usr/local/src/mod-pagespeed-stable_current.deb https://dl-ssl.google.com/dl/linux/direct/mod-pagespeed-stable_current_${facts['os']['architecture']}.deb",
creates => "/usr/local/src/mod-pagespeed-stable_current.deb";

"apache_mod_pagespeed_pkg_install":
Expand All @@ -101,7 +101,7 @@
"/etc/apache2/mods-available/pagespeed.conf":
ensure => file,
content => template("apache/mod_pagespeed.conf.erb"),
mode => 0444,
mode => "0444",
notify => Service["apache2"];
}
}
Expand All @@ -113,13 +113,13 @@

# Install the certbot package
package {
"python-certbot-apache": ensure => installed;
"python3-certbot-apache": ensure => installed;
}

file {
"/usr/local/bin/apache_setup_certbot":
ensure => file,
content => template("apache/setup_certbot.erb"),
mode => 0555;
mode => "0555";
}
}
Loading