Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate Travis jobs to GitHub actions #317

Open
wants to merge 74 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
3e077c7
Add lint workflow
ravichdev Mar 23, 2021
5fe3375
Update workflow name
ravichdev Mar 23, 2021
0b2efe1
Add e2e test job
ravichdev Mar 23, 2021
8e9ad2e
Add lint job as dep for test jobs
ravichdev Mar 23, 2021
c5a3bd0
Fix lint issue
ravichdev Mar 23, 2021
ce454aa
Disable TTY allocation
ravichdev Mar 23, 2021
3d4edb1
Add PHP tets job
ravichdev Mar 23, 2021
61f908a
Add compser install step
ravichdev Mar 23, 2021
3a6314a
Add env vars
ravichdev Mar 23, 2021
4833fb5
Remove DIFF_HEAD and add env debug step
ravichdev Mar 23, 2021
4e7b4d8
Update js and e2e coveralls steps
ravichdev Mar 24, 2021
1abd9f9
Set coveralls to parallel
ravichdev Mar 24, 2021
82163aa
Add PHP Unittest job
ravichdev Mar 24, 2021
a01e1b5
Update phpunit test command
ravichdev Mar 24, 2021
34a6421
Add debug/print statements
ravichdev Mar 24, 2021
15448c3
Add more print statements
ravichdev Mar 24, 2021
1854e26
Add more print statements
ravichdev Mar 24, 2021
8e47209
Remove failing grep
ravichdev Mar 24, 2021
43a5a68
Add mysql port
ravichdev Mar 24, 2021
35ecf95
Disable all jobs except phpunit
ravichdev Mar 24, 2021
46692d4
Fix incorrect job steps
ravichdev Mar 24, 2021
dc3d12b
Remove lint dep
ravichdev Mar 24, 2021
1c7ec0c
Use default mysql service in the ubuntu image
ravichdev Mar 24, 2021
f86cf1a
Update mysql port and remove DB drop command
ravichdev Mar 24, 2021
a7b0177
Print MySQL version
ravichdev Mar 24, 2021
8c89a8d
Update tests dir
ravichdev Mar 24, 2021
99e4ccc
Add phpunit bootstrap debug print statements
ravichdev Mar 24, 2021
3c04a2c
Update default WP_TESTS_DIR path
ravichdev Mar 24, 2021
562330d
code refactor and cleanup
ravichdev Mar 24, 2021
19e7ffe
Set vars at script level scope
ravichdev Mar 24, 2021
b6edb9d
Move download function to top
ravichdev Mar 24, 2021
47aac99
Run tests in the installed path
ravichdev Mar 24, 2021
c598f5c
Set working directory
ravichdev Mar 24, 2021
5837bef
Update env var
ravichdev Mar 24, 2021
996fdf7
Add debug step
ravichdev Mar 24, 2021
06a38fe
Update script to run tests after install
ravichdev Mar 24, 2021
9419bb7
Cleanup script
ravichdev Mar 24, 2021
85f5546
Code refactor and cleanup
ravichdev Mar 24, 2021
7446d7e
Add php coveralls
ravichdev Mar 24, 2021
457b7b6
Add coveralls clover
ravichdev Mar 24, 2021
215ea21
Update clover path
ravichdev Mar 24, 2021
2274d05
Update composer script to run coverage
ravichdev Mar 24, 2021
a4c9e64
Replace test command
ravichdev Mar 24, 2021
170a36d
Remove .coveralls.yml file
ravichdev Mar 24, 2021
a2e385b
Add coveralls.yml with json_path
ravichdev Mar 24, 2021
afc356e
Add COVERALLS_REPO_TOKEN
ravichdev Mar 24, 2021
0efe1fb
Add PHP and WP version matrix
ravichdev Mar 24, 2021
68a18aa
Fix syntax error
ravichdev Mar 24, 2021
7e53fa8
Update matrix to use include
ravichdev Mar 24, 2021
a1a9265
Update WP version to '5.0'
ravichdev Mar 24, 2021
9427cff
Set PHPUnit version
ravichdev Mar 24, 2021
36ff513
Use PHPUnit 5 for older PHP versions
ravichdev Mar 24, 2021
103a5cf
Update if condition
ravichdev Mar 24, 2021
85e140f
Fix syntax error
ravichdev Mar 24, 2021
5c4bca8
Force update deps
ravichdev Mar 24, 2021
57fabc3
Remove phpcov for phpunit5
ravichdev Mar 24, 2021
356f9b7
Remove all composer packages to prevent PHP version issues
ravichdev Mar 24, 2021
1a0dc21
Update composer install and remove sequence
ravichdev Mar 24, 2021
26ee81c
DOnt use scripts
ravichdev Mar 24, 2021
937b8f3
Use --no-scripts
ravichdev Mar 24, 2021
ba014fd
Install phpunit directly for older PHP versions
ravichdev Mar 24, 2021
ba2388c
MySQL use mysql_native_password authentication for back compat
ravichdev Mar 24, 2021
489b4d8
Run as sudo
ravichdev Mar 24, 2021
f444c96
Update mysql conf file
ravichdev Mar 24, 2021
f7aecfb
Use ubuntu-18.04 for PHP7.0 and 5.6
ravichdev Mar 24, 2021
65e169e
Update ubuntu version
ravichdev Mar 24, 2021
ffd2b2a
Update OS var
ravichdev Mar 24, 2021
17775d6
Cleanup
ravichdev Mar 24, 2021
43a092e
Add missing OS var
ravichdev Mar 24, 2021
ab337ee
Enable JS and E2E test jobs
ravichdev Mar 24, 2021
e9f2c58
Update print statement to include WP version
ravichdev Mar 24, 2021
b4bf2c6
Rename actions file and fix coveralls issue
ravichdev Mar 24, 2021
5a7cb83
Remove test branch from push branches list
ravichdev Mar 24, 2021
9484070
Refactor and cleanup workflow yaml file
ravichdev Mar 25, 2021
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
5 changes: 2 additions & 3 deletions .coveralls.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
service_name: travis-ci
coverage_clover: build/logs/clover.xml
json_path: build/logs/coveralls-upload.json
coverage_clover: tests/coverage/clover.xml
json_path: tests/coverage/coveralls-upload.json
162 changes: 162 additions & 0 deletions .github/workflows/lint-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
name: Coding Standards and Tests

Choose a reason for hiding this comment

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

I think it is cleaner to have this as different workflows in different files.

A good example of this would this project - https://github.com/google/web-stories-wp/tree/main/.github/workflows

I would break into following files.

  • test-php.yml
  • test-js.yml
  • lint-js-css.yml
  • lint-php.yml
  • test-e2e.yml


on:
push:
branches:
- master

Choose a reason for hiding this comment

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

Should this be main or include main

- develop
pull_request:

jobs:
lint:
name: "Coding Standards"
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: "14"

- name: Install dependencies
run: npm ci

- name: Run coding standards check
run: npm run lint

Choose a reason for hiding this comment

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

You can pipe lint results into cs2pr. This will highlight the line errors. Here is an example.

https://github.com/google/web-stories-wp/blob/458499e8178d5e911d18504829666ce29d7ae85a/.github/workflows/lint-php.yml#L67


test-e2e:
needs: [lint]
name: "E2E tests (PHP 7.4, WordPress latest, with code coverage)"
runs-on: ubuntu-latest

env:
NODE_ENV: e2e
WP_VERSION: 5.7

Choose a reason for hiding this comment

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

Why is this hardcoded to 5.7? Travis just uses latest
https://github.com/xwp/wp-foo-bar/blob/develop/.travis.yml#L71


steps:
- uses: actions/checkout@v2
- uses: hmarr/debug-action@v2
- uses: actions/setup-node@v1
with:
node-version: "14"

- name: Install dependencies
run: npm ci

Choose a reason for hiding this comment

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

Dont we need to composer install as well here?

- name: Build assets
run: npm run build:js

- name: Start docker local env
run: npm run env:start

- name: Install WordPress
run: |
npm run wp -- wp core install --title=WordPress --admin_user=admin --admin_password=password [email protected] --skip-email --url=http://localhost:8088 --quiet
npm run wp -- wp plugin activate foo-bar

- name: Run E2E tests with coverage
run: npm run test:e2e:coverage

- name: Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: ./tests/coverage/e2e/lcov.info
flag-name: "E2E Tests"
parallel: true

test-js:
needs: [lint]
name: "JS unit tests (with code coverage)"
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: "14"

- name: Install dependencies
run: npm ci

- name: Run JS tests
run: npm run test:js:coverage

- name: Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: ./tests/coverage/js/lcov.info
flag-name: "JS Unit Tests"
parallel: true

test-php:
needs: [lint]
name: "PHP tests (PHP ${{ matrix.php_versions }}, WordPress ${{ matrix.wp_versions }})"
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
php_versions: [7.4, 7.3, 7.2, 7.1]

Choose a reason for hiding this comment

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

Should we add PHP 8 here.

wp_versions: ["latest"]
os: [ubuntu-latest]
include:
- php_versions: 7.4
wp_versions: "trunk"
os: ubuntu-latest

- php_versions: "7.0"
wp_versions: "latest"
os: ubuntu-18.04 # Use ubuntu-18.4 which has MySQL 5.7 for back-compat < PHP7.0

- php_versions: 5.6.20
wp_versions: "latest"
os: ubuntu-18.04

- php_versions: 5.6.20
wp_versions: "5.0"
os: ubuntu-18.04

env:
WP_VERSION: ${{ matrix.wp_versions }}
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_PARALLEL: true
COVERALLS: ${{ matrix.php_versions == 7.4 && matrix.wp_versions == 'latest' }}

steps:
- uses: actions/checkout@v2
- name: Setup PHP ${{ matrix.php_versions }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php_versions }}
tools: phpunit

- name: Start MySQL
run: |
sudo systemctl enable mysql.service
sudo systemctl start mysql.service

- name: Install dependencies
run: composer install

- name: Install and Run tests
if: ${{ matrix.php_versions == '7.0' || matrix.php_versions == '5.6.20' }}
run: |
wget -O bin/phpunit https://phar.phpunit.de/phpunit-5.phar
chmod +x bin/phpunit
source bin/php-tests.sh wordpress_test root root localhost false bin/phpunit
Comment on lines +142 to +147

Choose a reason for hiding this comment

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

You can install via composer.


- name: Install and Run tests
if: ${{ matrix.php_versions != '7.0' && matrix.php_versions != '5.6.20' }}
run: source bin/php-tests.sh wordpress_test root root localhost

finish:
needs: [test-e2e, test-js, test-php]
name: Finish
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.github_token }}
parallel-finished: true
Loading