Skip to content
This repository has been archived by the owner on Nov 15, 2022. It is now read-only.

Commit

Permalink
fix(ci): migration from Travis CI to github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
KaiSchwarz-cnic committed Jan 27, 2021
1 parent 69bd58e commit 8f9247e
Show file tree
Hide file tree
Showing 6 changed files with 211 additions and 358 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Release
on: [push, pull_request]

jobs:
test:
name: Test @ PHP ${{ matrix.php-version }} - x86 - ubuntu-latest
# Support [skip ci] out of box with github actions Workaround
# Only works for push https://github.com/actions/runner/issues/774
if: github.event_name == 'pull_request' || (github.event_name == 'push' && contains(toJson(github.event.commits), '[skip ci]') == false)
strategy:
matrix:
php-version:
- 7.4
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup NodeJS LTS
uses: actions/setup-node@v2
- name: Install dependencies
run: |
npm prune
npm i
- name: Install Dependencies::PHP${{ matrix.php-version }}
run: |
echo "$HOME/.composer/vendor/bin" >> $GITHUB_PATH
composer global require phpunit/phpunit dealerdirect/phpcodesniffer-composer-installer roave/security-advisories:dev-master squizlabs/php_codesniffer phpcompatibility/php-compatibility
# TODO migrate the below to gulp calls
- name: Check PHP Compatibility
run: phpcs --standard=PHPCompatibility -q -n --colors --runtime-set testVersion ${{ matrix.php-version }} --extensions=php --ignore=node_modules,vendor,templates_c . || exit 1;
- name: Check PSR12 Standard
run: phpcs --standard=PSR12 -q -n --colors --extensions=php,inc,lib --ignore=node_modules,vendor,templates_c .
- name: Run tests
run: phpunit
release:
name: Release @ NodeJS LTS - x86 - ubuntu-latest
runs-on: ubuntu-latest
needs:
- test
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
persist-credentials: false
- name: Setup NodeJS LTS
uses: actions/setup-node@v2
- name: Install dependencies
run: |
npm prune
npm i
- name: Release
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
WHMCSMP_LOGIN: ${{ secrets.WHMCSMP_LOGIN }}
WHMCSMP_PASSWORD: ${{ secrets.WHMCSMP_PASSWORD }}
WHMCSMP_PRODUCTID: ${{ secrets.WHMCSMP_PRODUCTID_ISPAPI_PRICINGIMPORT }}
run: npx semantic-release
36 changes: 0 additions & 36 deletions .travis.yml

This file was deleted.

117 changes: 117 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
const { series, src, dest } = require('gulp')
const clean = require('gulp-clean')
const zip = require('gulp-zip')
const tar = require('gulp-tar')
const gzip = require('gulp-gzip')
const exec = require('util').promisify(require('child_process').exec)
const cfg = require('./gulpfile.json')

/**
* Perform PHP Linting
*/
async function doLint () {
// these may fail, it's fine
try {
await exec(`${cfg.phpcsfixcmd} ${cfg.phpcsparams}`)
} catch (e) {
}

// these shouldn't fail
try {
await exec(`${cfg.phpcschkcmd} ${cfg.phpcsparams}`)
await exec(`${cfg.phpcomptcmd} ${cfg.phpcsparams}`)
// await exec(`${cfg.phpstancmd}`);
} catch (e) {
await Promise.reject(e.message)
}
await Promise.resolve()
}

/**
* cleanup old build folder / archive
* @return stream
*/
function doDistClean () {
return src([cfg.archiveBuildPath, `${cfg.archiveFileName}-latest.zip`], { read: false, base: '.', allowEmpty: true })
.pipe(clean({ force: true }))
}

/**
* Copy all files/folders to build folder
* @return stream
*/
function doCopyFiles () {
return src(cfg.filesForArchive, { base: '.' })
.pipe(dest(cfg.archiveBuildPath))
}

/**
* Clean up files
* @return stream
*/
function doFullClean () {
return src(cfg.filesForCleanup, { read: false, base: '.', allowEmpty: true })
.pipe(clean({ force: true }))
}

/**
* build latest zip archive
* @return stream
*/
function doGitZip () {
return src(`./${cfg.archiveBuildPath}/**`)
.pipe(zip(`${cfg.archiveFileName}-latest.zip`))
.pipe(dest('.'))
}

/**
* build zip archive
* @return stream
*/
function doZip () {
return src(`./${cfg.archiveBuildPath}/**`)
.pipe(zip(`${cfg.archiveFileName}.zip`))
.pipe(dest('./pkg'))
}

/**
* build tar archive
* @return stream
*/
function doTar () {
return src(`./${cfg.archiveBuildPath}/**`)
.pipe(tar(`${cfg.archiveFileName}.tar`))
.pipe(gzip())
.pipe(dest('./pkg'))
}

exports.lint = series(
doLint
)

exports.copy = series(
doDistClean,
doCopyFiles
)

exports.prepare = series(
exports.lint,
exports.copy
)

exports.archives = series(
doGitZip,
doZip,
doTar
)

exports.default = series(
exports.prepare,
exports.archives,
doFullClean
)
exports.release = series(
exports.copy,
exports.archives,
doFullClean
)
23 changes: 23 additions & 0 deletions gulpfile.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"phpcsparams": "--extensions=php --ignore=node_modules,vendor,templates_c -q .",
"phpcsfixcmd": "phpcbf --standard=PSR12",
"phpcschkcmd": "phpcs -n --colors --standard=PSR12",
"phpcomptcmd": "phpcs -n --colors --standard=PHPCompatibility --runtime-set testVersion \"$(php -r 'echo PHP_MAJOR_VERSION . \".\" . PHP_MINOR_VERSION;')\"",
"phpstancmd": "./vendor/bin/phpstan analyse",
"archiveFileName": "whmcs-ispapi-pricingimporter",
"archiveBuildPath": "build",
"filesForArchive": [
"README.md",
"CONTRIBUTING.md",
"HISTORY.md",
"LICENSE",
"modules/**"
],
"filesForCleanup": [
"templates_c",
"composer.lock",
".phpunit.result.cache",
"package-lock.json",
"tmp"
]
}
17 changes: 11 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
},
"license": "MIT",
"engines": {
"node": ">=10.18.0"
"node": ">=10.18.0",
"npm": ">=6.13.4"
},
"homepage": "https://github.com/hexonet/whmcs-ispapi-pricingimporter",
"repository": "github:hexonet/whmcs-ispapi-pricingimporter.git",
Expand Down Expand Up @@ -44,14 +45,18 @@
"application"
],
"devDependencies": {
"npm": ">=6.13.4",
"semantic-release": "^17.0.2",
"@hexonet/semantic-release-github-whmcs-config": "^1.0.0"
"semantic-release": "^17.3.7",
"@hexonet/semantic-release-github-whmcs-config": "^1.3.7",
"gulp": "^4.0.2",
"gulp-clean": "^0.4.0",
"gulp-tar": "^3.1.0",
"gulp-gzip": "^1.4.2",
"gulp-zip": "^5.0.2"
},
"scripts": {
"phpCompatibility": "./scripts/phpcompatibility.sh",
"codeCheck": "phpcs --standard=PSR1,PSR2 -q -n --colors *.php templates tests",
"codeFix": "phpcbf --standard=PSR1,PSR2 -q *.php templates tests",
"codeCheck": "phpcs --standard=PSR12 -q -n --colors --extensions=php --ignore=node_modules,vendor,templates_c .",
"codeFix": "phpcbf --standard=PSR12 -q --extensions=php --ignore=node_modules,vendor,templates_c .",
"test": "phpunit"
}
}
Loading

0 comments on commit 8f9247e

Please sign in to comment.