Skip to content

Commit 35af3b8

Browse files
authored
Add github action to build the phpList package for release (#763)
* create composer.json with the required dependencies * put things in the right place with davidbarratt/custom-installer * add updater * add script to install plugin code * add some plugins * use bramleys version * update dependency * allow plugins from other vendors * add some more plugins * add some more plugins * ignore updater * rsync instead of mv * add bash script to run tests, meant to be run inside a docker container * flush privileges on login creation * add selenium drivers * run the tests * add Dockerfile for release verification * add behat file * test upload to S3 action * on tag of release * typo * add token to avoid rate limiting * on second step as well * upload to folder * use ssh key for github auth * try the http-auth way * fix php version * the theme is now installed with composer * selenium drivers are set up with composer * comment "debug step" that's failing * do not ignore composer.lock * try a new action * fix bucket name * update region * add workflow to build a release * copy test to test folder * lock php version * remove debug output * use var for the bucket * parse the version from the tag * switch to latest ubuntu * check s3cmd on 18.04 * go back to 18.04 * run as sudo * put folder back to avoid confusion * use RELEASE_VERSION * fix path * tidy up the zip files, to reduce size * put the zips in a different bucket * install plugins as a seperate step, as Composer skips it * show github ref * install required tools * avoid annoying incompatibility * go back to 18.04, there's a weird issue on mysql commandline in 20.04 * discover rsync location * remove trigger on test action * trigger the release build on tagging a new version * parse off the v of the version, to follow previous convention * remove failing PHP versions * update some files with the new version * typo
1 parent cd083f8 commit 35af3b8

File tree

11 files changed

+4471
-25
lines changed

11 files changed

+4471
-25
lines changed
Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
2+
name: Build Release
3+
4+
on:
5+
push:
6+
tags: v[1-9]+.[0-9]+.*
7+
8+
jobs:
9+
test:
10+
runs-on: ubuntu-18.04
11+
continue-on-error: ${{ matrix.experimental }}
12+
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
php-version: ['7.4']
17+
experimental: [false]
18+
19+
steps:
20+
- uses: actions/checkout@v2
21+
22+
- name: Find the version
23+
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/v}" >> $GITHUB_ENV
24+
25+
- name: Show the discovered version
26+
run: |
27+
echo $RELEASE_VERSION
28+
echo ${{ env.RELEASE_VERSION }}
29+
echo $GITHUB_REF
30+
echo ${{ env.GITHUB_REF }}
31+
32+
- name: Set up PHP ${{ matrix.php-version }}
33+
uses: shivammathur/setup-php@v2
34+
with:
35+
php-version: ${{ matrix.php-version }}
36+
37+
- name: Setup Packages
38+
run: |
39+
cd $GITHUB_WORKSPACE
40+
sudo apt update && sudo apt install -y rsync
41+
42+
- name: Cache Composer dependencies
43+
uses: actions/cache@v2
44+
with:
45+
path: /tmp/composer-cache
46+
key: ${{ matrix.php-version }}-${{ hashFiles('**/composer.lock') }}
47+
48+
- name: Install dependencies
49+
uses: php-actions/composer@v5
50+
with:
51+
dev: yes
52+
args: --prefer-dist --no-interaction
53+
php_version: 7.4
54+
php_extensions: xml
55+
version: 2
56+
57+
- name: Install Plugins
58+
run: |
59+
cd $GITHUB_WORKSPACE
60+
./scripts/install-plugins.sh vendor public_html/lists/admin/plugins/
61+
62+
- name: Create Database
63+
run: |
64+
sudo systemctl start mysql.service
65+
sudo mysql -proot -e 'drop database if exists phplistdb'
66+
sudo mysqladmin -proot create phplistdb
67+
sudo mysql -proot -e 'grant all on phplistdb.* to phplist@localhost identified by "phplist"'
68+
69+
- name: Start Test Server
70+
run: |
71+
cd $GITHUB_WORKSPACE
72+
cp -fv tests/default.behat.yml tests/behat.yml
73+
cp -fv tests/ci/config.php public_html/lists/config/config.php
74+
mkdir -p output/screenshots
75+
mkdir -p build/mails
76+
./bin/start-selenium > output/selenium.log 2>&1 &
77+
sleep 5
78+
sudo php -S 0.0.0.0:80 -t public_html > /dev/null 2>&1 &
79+
80+
- name: Check PHP syntax errors
81+
uses: overtrue/[email protected]
82+
with:
83+
path: ./public_html
84+
85+
- name: Report Versions
86+
run: |
87+
google-chrome --version
88+
php -v
89+
chromedriver -v
90+
geckodriver -V
91+
which geckodriver
92+
which chromedriver
93+
which rsync
94+
rsync --version
95+
firefox -v
96+
vendor/bin/behat -V
97+
98+
- name: Run BDD Tests
99+
run: |
100+
cd $GITHUB_WORKSPACE/tests
101+
../vendor/bin/behat -n -fprogress -p chrome --strict --stop-on-failure --tags=@initialise
102+
../vendor/bin/behat -n -fprogress -p chrome --strict --stop-on-failure --tags="~@initialise && ~@wip"
103+
104+
- name: Clean Up
105+
run: |
106+
cd $GITHUB_WORKSPACE
107+
cd ..
108+
mv phplist3 phplist-$RELEASE_VERSION
109+
sudo find . -type d -exec chmod 755 {} \;
110+
sudo find . -type f -exec chmod 644 {} \;
111+
cd phplist-$RELEASE_VERSION
112+
chmod 777 public_html/lists/admin/plugins
113+
cat public_html/lists/admin/init.php | tr '\n' '\r' | sed 's~//## remove on rollout.*//## end remove on rollout ###~define("VERSION","'${RELEASE_VERSION}'");~' | tr '\r' '\n' > /tmp/$$.init
114+
mv -f /tmp/$$.init public_html/lists/admin/init.php
115+
sed -i s~define\(\'STRUCTUREVERSION\'.*~define\(\'STRUCTUREVERSION\',\"${RELEASE_VERSION}\"\)\;~ public_html/lists/admin/structure.php
116+
sed -i s/^VERSION=/VERSION=${RELEASE_VERSION}/ VERSION
117+
118+
cd ..
119+
zip -rq9 phplist-${RELEASE_VERSION}.zip phplist-${RELEASE_VERSION}
120+
tar cf phplist-${RELEASE_VERSION}.tar phplist-${RELEASE_VERSION}
121+
122+
remove=(
123+
default.behat.yml
124+
TESTING.md
125+
.dotgitlab-ci.yml
126+
.travis.yml
127+
composer.json
128+
composer.lock
129+
.git
130+
.github
131+
.php_cs
132+
.gitmodules
133+
Dockerfile
134+
Vagrantfile
135+
.styleci.yml
136+
.gitignore
137+
.gitsvnextmodules
138+
tests
139+
output.log
140+
output
141+
build
142+
.phplist-cache
143+
docker_tag
144+
vendor
145+
public_html/lists/admin/tests
146+
scripts
147+
bin/start-selenium
148+
bin/fake-sendmail.sh
149+
bin/imgur-uploader.sh
150+
public_html/lists/base/tests
151+
public_html/lists/base/.htaccess
152+
public_html/lists/base/phpunit.xml.dist
153+
public_html/lists/base/composer.lock
154+
public_html/lists/base/composer.json
155+
public_html/lists/base/CODE_OF_CONDUCT.md
156+
public_html/lists/admin/ui/default
157+
)
158+
159+
for item in ${remove[@]}; do
160+
[[ -f phplist-$RELEASE_VERSION/$item ]] && {
161+
tar -vf phplist-${RELEASE_VERSION}.tar --delete phplist-$RELEASE_VERSION/$item
162+
zip -d phplist-${RELEASE_VERSION}.zip phplist-$RELEASE_VERSION/$item
163+
}
164+
[[ -d phplist-$RELEASE_VERSION/$item ]] && {
165+
tar -vf phplist-${RELEASE_VERSION}.tar --delete phplist-$RELEASE_VERSION/$item
166+
zip -d phplist-${RELEASE_VERSION}.zip phplist-$RELEASE_VERSION/$item/\*
167+
}
168+
done
169+
170+
gzip phplist-${RELEASE_VERSION}.tar
171+
mv phplist-${RELEASE_VERSION}.tar.gz phplist-${RELEASE_VERSION}.tgz
172+
173+
md5sum phplist-${RELEASE_VERSION}.* > phplist-${RELEASE_VERSION}.md5
174+
sha256sum phplist-${RELEASE_VERSION}.* > phplist-${RELEASE_VERSION}.sha256
175+
sha1sum phplist-${RELEASE_VERSION}.* > phplist-${RELEASE_VERSION}.sha1
176+
ls -l
177+
mv phplist-$RELEASE_VERSION phplist3
178+
cd $GITHUB_WORKSPACE
179+
180+
- name: Set up S3cmd cli tool
181+
uses: s3-actions/[email protected]
182+
with:
183+
provider: aws
184+
region: 'us-east-1'
185+
access_key: ${{ secrets.AWS_KEY_ID }}
186+
secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
187+
188+
- name: Upload the files
189+
run: |
190+
cd ..
191+
s3cmd put phplist-${RELEASE_VERSION}.* s3://${{ secrets.AWS_S3_VERSIONS_BUCKET }}/
192+
s3cmd put phplist3/public_html/lists/admin/images/power-phplist.png s3://${{ secrets.AWS_S3_POWERED_BUCKET }}/images/${RELEASE_VERSION}/

.github/workflows/main.yml

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,11 @@ jobs:
1111
strategy:
1212
fail-fast: false
1313
matrix:
14-
php-version: ['7.1', '7.2', '7.3', '7.4']
14+
php-version: ['7.2', '7.3', '7.4']
1515
experimental: [false]
1616
include:
1717
- php-version: '8.0'
1818
experimental: true
19-
- php-version: '7.0'
20-
experimental: true
2119

2220
steps:
2321
- uses: actions/checkout@v2
@@ -26,6 +24,8 @@ jobs:
2624
uses: shivammathur/setup-php@v2
2725
with:
2826
php-version: ${{ matrix.php-version }}
27+
env:
28+
COMPOSER_TOKEN: ${{ secrets.COMPOSER_TOKEN }}
2929

3030
- name: Setup Packages
3131
run: |
@@ -38,11 +38,17 @@ jobs:
3838
path: /tmp/composer-cache
3939
key: ${{ matrix.php-version }}-${{ hashFiles('**/composer.lock') }}
4040

41+
- name: Add HTTP basic auth credentials
42+
run: echo '${{ secrets.COMPOSER_AUTH_JSON }}' > $GITHUB_WORKSPACE/auth.json
43+
4144
- name: Install dependencies
4245
uses: php-actions/composer@v5
4346
with:
4447
dev: yes
4548
args: --prefer-dist --no-interaction
49+
php_version: 7.4
50+
php_extensions: xml
51+
version: 2
4652

4753
- name: Create Database
4854
run: |
@@ -51,13 +57,13 @@ jobs:
5157
sudo mysqladmin -proot create phplistdb
5258
sudo mysql -proot -e 'grant all on phplistdb.* to phplist@"%" identified by "phplist"'
5359
54-
- name: Set bootlist theme
55-
run: |
56-
cd $GITHUB_WORKSPACE/public_html/lists/admin/ui/
57-
wget https://github.com/phpList/phplist-ui-bootlist/archive/master.tar.gz
58-
tar -xzf master.tar.gz
59-
mv phplist-ui-bootlist-master phplist-ui-bootlist
60-
rm master.tar.gz
60+
# - name: Set bootlist theme
61+
# run: |
62+
# cd $GITHUB_WORKSPACE/public_html/lists/admin/ui/
63+
# wget https://github.com/phpList/phplist-ui-bootlist/archive/master.tar.gz
64+
# tar -xzf master.tar.gz
65+
# mv phplist-ui-bootlist-master phplist-ui-bootlist
66+
# rm master.tar.gz
6167

6268
- name: Start Test Server
6369
run: |
@@ -75,17 +81,16 @@ jobs:
7581
with:
7682
path: ./public_html
7783

78-
- name: Report Versions
79-
run: |
80-
google-chrome --version
81-
php -v
82-
chromedriver -v
83-
geckodriver -V
84-
which geckodriver
85-
which chromedriver
86-
firefox -v
87-
vendor/bin/behat -V
88-
cd vendor/bin/ && sudo ln -s /usr/bin/chromedriver && sudo ln -s /usr/bin/geckodriver
84+
# - name: Report Versions
85+
# run: |
86+
# google-chrome --version
87+
# php -v
88+
# chromedriver -v
89+
# geckodriver -V
90+
# which geckodriver
91+
# which chromedriver
92+
# firefox -v
93+
# vendor/bin/behat -V
8994

9095
- name: Run BDD Tests
9196
run: |
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
3+
name: Upload to S3
4+
5+
on:
6+
push:
7+
tags: testing-[1-9]+.[0-9]+.[0-9]+
8+
9+
jobs:
10+
upload:
11+
runs-on: ubuntu-18.04
12+
steps:
13+
- uses: actions/checkout@master
14+
# - uses: shallwefootball/s3-upload-action@master
15+
# with:
16+
# aws_key_id: ${{ secrets.AWS_KEY_ID }}
17+
# aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY}}
18+
# aws_bucket: ${{ secrets.AWS_BUCKET }}
19+
# source_dir: 'doc'
20+
# destination_dir: '/test'
21+
- name: Set up S3cmd cli tool
22+
uses: s3-actions/[email protected]
23+
with:
24+
provider: aws # default is linode
25+
region: 'us-east-1'
26+
access_key: ${{ secrets.AWS_KEY_ID }}
27+
secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
28+
- name: Interact with object storage
29+
run: |
30+
s3cmd sync --recursive --acl-public doc s3://powered.phplist/test/
31+
s3cmd info s3://powered.phplist

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/.svn/
22
/plugins
33
vendor/
4-
composer.lock
54
/behat.yml
65
.php_cs.cache
76
/.idea/
@@ -11,3 +10,4 @@ public_html/lists/admin/info/
1110
/build
1211
.DS_Store
1312
.vagrant
13+
/updater

Dockerfile

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
FROM debian:buster-slim
3+
4+
LABEL maintainer="[email protected]"
5+
6+
RUN apt -y update && apt -y upgrade
7+
8+
RUN apt install -y -qq postfix
9+
10+
RUN apt install -y php-cli mariadb-server bash sudo composer git php-curl php-mysqli php-dom make firefox-esr wget
11+
## otherwise jdk fails, https://github.com/geerlingguy/ansible-role-java/issues/64
12+
RUN mkdir -p /usr/share/man/man1
13+
RUN apt install -y default-jdk
14+
15+
RUN wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb && apt -y install ./google-chrome-stable_current_amd64.deb
16+
17+
## debugging utils, that can be removed once it works
18+
RUN apt install -y vim curl telnet psutils
19+
20+
RUN useradd -m -s /bin/bash -d /home/phplist phplist
21+
22+
COPY . /var/www/phplist3
23+
RUN chown -R phplist: /var/www
24+
USER phplist
25+
WORKDIR /var/www/phplist3/
26+
RUN rm -rf vendor
27+
28+
29+
ENTRYPOINT [ "./scripts/run-tests.sh" ]
30+
31+
#ENTRYPOINT [ "/bin/bash" ]

0 commit comments

Comments
 (0)