Skip to content

Commit 80871ba

Browse files
authored
Merge pull request #94 from triplepoint/feature/ci_modernization
Feature/ci modernization
2 parents 9c68bcb + f464253 commit 80871ba

File tree

14 files changed

+113
-124
lines changed

14 files changed

+113
-124
lines changed

.github/workflows/php.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: PHP Composer
2+
3+
on:
4+
push:
5+
pull_request:
6+
branches: [ "master" ]
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
run:
13+
runs-on: ${{ matrix.operating-system }}
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
operating-system: [ubuntu-latest]
18+
php-versions:
19+
- '7.4'
20+
# - '8.0'
21+
# - '8.1'
22+
# - '8.2'
23+
# - '8.3'
24+
# - '8.4'
25+
26+
name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }}
27+
28+
steps:
29+
- name: Checkout
30+
uses: actions/checkout@v4
31+
32+
- name: Install PHP
33+
uses: shivammathur/setup-php@v2
34+
with:
35+
php-version: ${{ matrix.php-versions }}
36+
37+
- name: Check PHP Version
38+
run: php -v
39+
40+
- name: Validate composer.json and composer.lock
41+
run: composer validate --strict
42+
43+
- name: Install dependencies
44+
run: composer install --prefer-dist --no-progress
45+
46+
- name: Run lint check
47+
run: composer run-script lint
48+
49+
- name: Run test suite
50+
run: composer run-script test

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,3 @@ Desktop.ini
2222
## From https://github.com/github/gitignore
2323
### SASS Ignores - "Sassy CSS" http://sass-lang.com/
2424
*.sass-cache
25-
26-
# Vagrant files
27-
/.vagrant/

.travis.yml

Lines changed: 0 additions & 30 deletions
This file was deleted.

Dockerfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM php:7.4-cli
2+
3+
RUN apt-get update && apt-get install -y --no-install-recommends \
4+
git \
5+
curl \
6+
unzip \
7+
&& rm -rf /var/lib/apt/lists/*
8+
9+
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin && ln -s /usr/local/bin/composer.phar /usr/local/bin/composer
10+
11+
RUN git config --global --add safe.directory /project
12+
13+
WORKDIR /project

README.md

Lines changed: 7 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -286,37 +286,14 @@ The workflow for this repository goes as follows:
286286
End users of this repository should only use tagged commits in production. Users interested in the current 'soon-to-be-released' code may use `master`, with the understanding that it may change unexpectedly. All other existing branches (if any) should be considered 'feature' branches in development, and not yet ready for use.
287287

288288
### Local Testing Environment
289-
There's a Vagrant virtual machine configuration included which is suitable for running the necessary unit tests. To bring up the machine, make sure you have Vagrant and Virtualbox installed, and from the project root directory:
289+
There's a `Dockerfile` and a set of helper scripts in `scripts/` suitable for running the necessary unit tests. With Docker installed, do:
290290

291+
``` shell
292+
# Execute the lint checks
293+
./script/lint
291294

292-
``` bash
293-
vagrant up
294-
vagrant ssh
295-
cd /project
295+
# Execute the unit tests
296+
./script/test
296297
```
297298

298-
### Setting Up for Testing
299-
The virtual machine development environment already has Composer installed. Once you're ssh'ed into the virtual machine, install this project's dev dependencies:
300-
301-
``` bash
302-
rm -rf vendor
303-
composer.phar update --verbose --prefer-dist
304-
```
305-
306-
### Unit Tests
307-
All the tests associated with this project can be manually run with:
308-
309-
``` bash
310-
vendor/bin/phpunit -c ./tests/phpunit.xml.dist ./tests
311-
```
312-
313-
### CodeSniffer
314-
Codesniffer verifies that coding standards are being met. Once the project is built with development dependencies, you can run the checks with:
315-
316-
``` bash
317-
vendor/bin/phpcs --encoding=utf-8 --extensions=php --standard=./tests/phpcs.xml -nsp ./
318-
```
319-
320-
### Continuous Integration
321-
The above tests are automatically run against Github commits with Travis-CI.
322-
- https://travis-ci.org/PhpUnitsOfMeasure/php-units-of-measure
299+
In addition, `./script/shell` will get you a bash shell in a temporary container. Note that the hosts directory is mounted into the container, and changes to files inside the container will persist.

Vagrantfile

Lines changed: 0 additions & 27 deletions
This file was deleted.

composer.json

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,45 @@
11
{
2-
"name": "php-units-of-measure/php-units-of-measure",
3-
2+
"name": "php-units-of-measure/php-units-of-measure",
43
"description": "A PHP library for converting between standard units of measure.",
5-
64
"keywords": [
7-
"measurements", "data", "conversion"
8-
],
9-
10-
"homepage": "https://github.com/PhpUnitsOfMeasure/php-units-of-measure",
11-
5+
"measurements",
6+
"data",
7+
"conversion"
8+
],
9+
"homepage": "https://github.com/PhpUnitsOfMeasure/php-units-of-measure",
1210
"license": "MIT",
13-
1411
"authors": [
1512
{
16-
"name": "Jonathan Hanson",
17-
"email": "[email protected]",
18-
"homepage": "http://www.jonathan-hanson.org/",
19-
"role": "Developer"
13+
"name": "Jonathan Hanson",
14+
"role": "Developer"
2015
}
2116
],
22-
2317
"support": {
24-
"email": "[email protected]",
2518
"issues": "https://github.com/PhpUnitsOfMeasure/php-units-of-measure/issues",
2619
"source": "https://github.com/PhpUnitsOfMeasure/php-units-of-measure"
2720
},
28-
2921
"require": {
30-
"php": ">=5.5.0"
22+
"php": ">=7.4.0"
3123
},
32-
3324
"require-dev": {
34-
"phpunit/phpunit": "4.8.*",
35-
"squizlabs/php_codesniffer": "2.8.1"
25+
"phpunit/phpunit": "5.*",
26+
"squizlabs/php_codesniffer": "3.7.2"
3627
},
37-
3828
"replace": {
3929
"triplepoint/php-units-of-measure": "*"
4030
},
41-
4231
"autoload": {
4332
"psr-4": {
4433
"PhpUnitsOfMeasure\\": "source/"
4534
}
4635
},
4736
"autoload-dev": {
4837
"psr-4": {
49-
"PhpUnitsOfMeasureTest\\": "tests/"
38+
"PhpUnitsOfMeasureTest\\": "tests/"
5039
}
40+
},
41+
"scripts": {
42+
"test": "phpunit -c ./tests/phpunit.xml.dist ./tests",
43+
"lint": "phpcs --encoding=utf-8 --extensions=php --standard=./tests/phpcs.xml -nsp ./"
5144
}
5245
}

scripts/lint

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
docker build -t "php-units-of-measure:dev" .
5+
docker run -it --rm -v `pwd`:/project "php-units-of-measure:dev" composer run-script lint

scripts/shell

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
docker build -t "php-units-of-measure:dev" .
5+
docker run -it --rm -v `pwd`:/project "php-units-of-measure:dev" bash

scripts/test

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
docker build -t "php-units-of-measure:dev" .
5+
docker run -it --rm -v `pwd`:/project "php-units-of-measure:dev" composer run-script test

0 commit comments

Comments
 (0)