Skip to content

PHPLIB-606: Move CI checks from travis-ci to GitHub Actions #802

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

Merged
merged 11 commits into from
Jan 20, 2021
Merged
68 changes: 68 additions & 0 deletions .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: "Coding Standards"

on:
pull_request:
branches:
- "v*.*"
- "master"
push:
branches:
- "v*.*"
- "master"

jobs:
coding-standards:
name: "Coding Standards"
runs-on: "ubuntu-20.04"

strategy:
matrix:
php-version:
- "7.4"

steps:
- name: "Checkout"
uses: "actions/checkout@v2"

- name: Setup cache environment
id: extcache
uses: shivammathur/cache-extensions@v1
Copy link
Member

Choose a reason for hiding this comment

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

Are there any concerns with depending on third-party repositories for action recipes? I imagine if this was taken down our CI builds would break (among many others). Might there be security concerns we were using encrypted environment variables (e.g. Atlas testing) and an action dependency was compromised?

AFAIK, secrets are only tested with Evergreen so this may be a hypothetical question.

Copy link
Member Author

Choose a reason for hiding this comment

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

Are there any concerns with depending on third-party repositories for action recipes? I imagine if this was taken down our CI builds would break (among many others).

Yes, our CI builds would break in that case, but I'd expect a fork to spring up relatively soon considering how widely used these actions are.

Might there be security concerns we were using encrypted environment variables (e.g. Atlas testing) and an action dependency was compromised?

Good question, I haven't considered yet. Quoting from the secrets documentation:

To make a secret available to an action, you must set the secret as an input or environment variable in the workflow file. [...] You can use and read encrypted secrets in a workflow file if you have access to edit the file.

Reading this, any secrets defined in our org or repo would have to be passed on to third-party actions as input or environment variables (either using with or env keys). I'd assume that a compromised third-party action file would not gain access to secrets defined in our repository, but I concede I haven't tested this (yet).

That said, I haven't configured any secrets yet, so we're not running any AWS tests or anything. We can decide to do this at a later date, or we can leave testing with secrets to our evergreen pipeline.

Copy link
Member

Choose a reason for hiding this comment

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

That said, I haven't configured any secrets yet, so we're not running any AWS tests or anything. We can decide to do this at a later date, or we can leave testing with secrets to our evergreen pipeline.

I'd say nothing to do here, but something to keep in mind if you have grander plans for moving drivers onto GitHub Actions down the line. Maybe you want to add a line about this in your scope doc, but I reckon it's potentially future work since you were only focused on a subset of tests for quick PR feedback.

Copy link
Member Author

Choose a reason for hiding this comment

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

Will do to make sure other engineers are aware, although I want this to be a subset for quick PR feedback in all drivers for the time being.

with:
php-version: ${{ matrix.php-version }}
extensions: "mongodb"
key: "extcache-v1"

- name: Cache extensions
uses: actions/cache@v2
with:
path: ${{ steps.extcache.outputs.dir }}
key: ${{ steps.extcache.outputs.key }}
restore-keys: ${{ steps.extcache.outputs.key }}

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
extensions: "mongodb"
php-version: "${{ matrix.php-version }}"
tools: "cs2pr"

- name: "Show driver information"
run: "php --ri mongodb"

- name: "Cache dependencies installed with Composer"
uses: "actions/cache@v2"
with:
path: "~/.composer/cache"
key: "php-${{ matrix.php-version }}-composer-locked-${{ hashFiles('composer.lock') }}"
restore-keys: "php-${{ matrix.php-version }}-composer-locked-"

- name: "Require doctrine/coding-standard"
run: "composer require --no-update doctrine/coding-standard=^6.0"

- name: "Install dependencies with Composer"
run: "composer install --no-interaction --no-progress --no-suggest"

# The -q option is required until phpcs v4 is released
- name: "Run PHP_CodeSniffer"
run: "vendor/bin/phpcs -q --no-colors --report=checkstyle | cs2pr"
97 changes: 97 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: "Tests"

on:
pull_request:
branches:
- "v*.*"
- "master"
push:
branches:
- "v*.*"
- "master"

jobs:
phpunit:
name: "PHPUnit tests"
runs-on: "${{ matrix.os }}"

strategy:
fail-fast: true
matrix:
os:
- "ubuntu-20.04"
php-version:
- "7.4"
- "8.0"
mongodb-version:
- "4.4"
driver-version:
- "stable"
topology:
- "server"
include:
- os: "ubuntu-20.04"
php-version: "8.0"
mongodb-version: "4.4"
driver-version: "stable"
topology: "replica_set"
- os: "ubuntu-20.04"
php-version: "8.0"
mongodb-version: "4.4"
driver-version: "stable"
topology: "sharded_cluster"

steps:
- name: "Checkout"
uses: "actions/checkout@v2"
with:
fetch-depth: 2

- id: setup-mongodb
uses: mongodb-labs/drivers-evergreen-tools@master
with:
version: ${{ matrix.mongodb-version }}
topology: ${{ matrix.topology }}

- name: Setup cache environment
id: extcache
uses: shivammathur/cache-extensions@v1
with:
php-version: ${{ matrix.php-version }}
extensions: "mongodb-${{ matrix.driver-version }}"
key: "extcache-v1"

- name: Cache extensions
uses: actions/cache@v2
with:
path: ${{ steps.extcache.outputs.dir }}
key: ${{ steps.extcache.outputs.key }}
restore-keys: ${{ steps.extcache.outputs.key }}

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
php-version: "${{ matrix.php-version }}"
tools: "pecl"
extensions: "mongodb-${{ matrix.driver-version }}"
coverage: "none"
ini-values: "zend.assertions=1"

- name: "Show driver information"
run: "php --ri mongodb"

- name: "Cache dependencies installed with composer"
uses: "actions/cache@v2"
with:
path: "~/.composer/cache"
key: "php-${{ matrix.php-version }}-composer-locked-${{ hashFiles('composer.lock') }}"
restore-keys: "php-${{ matrix.php-version }}-composer-locked-"

- name: "Install dependencies with composer"
run: "composer update --no-interaction --no-progress"

- name: "Run PHPUnit"
run: "vendor/bin/simple-phpunit -v"
env:
SYMFONY_DEPRECATIONS_HELPER: 999999
MONGODB_URI: ${{ steps.setup-mongodb.outputs.cluster-uri }}
93 changes: 0 additions & 93 deletions .travis.yml

This file was deleted.

10 changes: 0 additions & 10 deletions .travis/debug-core.sh

This file was deleted.

6 changes: 0 additions & 6 deletions .travis/get_uri.php

This file was deleted.

40 changes: 0 additions & 40 deletions .travis/install-extension.sh

This file was deleted.

Loading