forked from WordPress/wordcamp.org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.travis.yml
53 lines (49 loc) · 2.32 KB
/
.travis.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# Travis CI configuration file.
# @link https://travis-ci.org/
# Declare project language and PHP versions to test against.
# @link http://about.travis-ci.org/docs/user/languages/php/
language: php
php:
- 7.2
before_script:
# Print system info for debugging.
- node --version
- npm --version
- timedatectl
jobs:
include:
# To keep things clean, we set up separate jobs for Travis per project.
- name: "Blocks"
install:
- nvm install && nvm use
- npm install npm -g
# `npm ci` runs a "clean install"
- npm --prefix=$TRAVIS_BUILD_DIR/public_html/wp-content/mu-plugins/blocks ci
script:
- cd public_html/wp-content/mu-plugins/blocks
# Run eslint & stylelint over all JS/SCSS files
# @todo Find a way to only run on changed files
- npm run lint:js -- --config=./.eslintrc.js
- npm run lint:css
# Make sure the build completes.
- npm run build
- name: "PHP Code Standards"
# Only run if we're on the "pull request build", otherwise CHANGED_FILES is empty.
if: branch = production
install:
- composer install
script:
# Create an empty PHP file, which will be passed to the linter along with all the changed files.
# Otherwise, the linter will get no args, and attempt to lint the entire repo.
- touch $TRAVIS_BUILD_DIR/tmp.php
# Exporting list of changed files in CHANGED_FILES variable
# diff: Get the changed files
# --name-only: Get only name of changed files
# --diff-filter=AM: Get only (A)dded or (M)odified files. We do not care about deleted files for coding standard test.
# $TRAVIS_BRANCH: Base branch we want to merge. Usually this will be master
# $TRAVIS_BRANCH...HEAD: List of commits not present in $TRAVIS_BRANCH, but present in HEAD
# tr '\n' ' ': Convert from list of filenames seperated by `\n` to list of filenames seperated by ' '
- export CHANGED_FILES=$(git diff --name-only --diff-filter=AM $TRAVIS_BRANCH...HEAD | tr '\n' ' ')
# Run phpcs installed via composer, only run over changed files.
# tmp.php: So that phpcs do not assume that it has to scan all files in case no php files are changed.
- composer run-script phpcs $TRAVIS_BUILD_DIR/tmp.php $(echo $CHANGED_FILES) -- -n