Skip to content

Commit

Permalink
Merge pull request eXist-db#600 from duncdrum/feat-gha
Browse files Browse the repository at this point in the history
Feat github action
  • Loading branch information
duncdrum authored Feb 2, 2021
2 parents 970ea30 + 86f44de commit fd3d2aa
Show file tree
Hide file tree
Showing 14 changed files with 306 additions and 116 deletions.
File renamed without changes.
12 changes: 0 additions & 12 deletions .github/move.yml

This file was deleted.

8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ Some of the answers, such as username will be stored after the initial run of th

If you want to contribute another template or option, please take a look at the issue tracker. Pull request are always welcome. This generator uses `mocha` for unit testing. Please make sure to add tests when opening a PR.

This application uses [Angular Commit Message Conventions](https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#-git-commit-guidelines) to determine semantic versioning of releases, please adhere to these conventions, like so:

| Commit message | Release type |
|-----------------|--------------|
| `fix(pencil): stop graphite breaking when too much pressure applied` | Patch Release |
| `feat(pencil): add 'graphiteWidth' option` | ~~Minor~~ Feature Release |
| `perf(pencil): remove graphiteWidth option`<br/><br/>`BREAKING CHANGE: The graphiteWidth option has been removed.`<br/>`The default graphite width of 10mm is always used for performance reasons.` | ~~Major~~ Breaking Release |

## License

MIT © [Duncan Paterson](https://github.com/duncdrum)
Expand Down
47 changes: 35 additions & 12 deletions generators/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,14 @@ module.exports = class extends Generator {
return 'Must be a string of 9 unix permission flags (rwx-)'
}
},
{
type: 'list',
choices: ['travis', 'GitHub Action'],
name: 'ci',
message: 'Whats your CI service',
default: 'GitHub Action',
store: true
},
{
type: 'confirm',
name: 'docker',
Expand Down Expand Up @@ -761,9 +769,13 @@ module.exports = class extends Generator {
this.templatePath('github/.gitattributes'),
this.destinationPath('.gitattributes')
)
this.fs.copy(
this.templatePath('github/feature_request.md'),
this.destinationPath('.github/ISSUE_TEMPLATE/feature_request.md')
)
this.fs.copy(
this.templatePath('github/PULL_REQUEST_TEMPLATE.md'),
this.destinationPath('.github/PULL_REQUEST_TEMPLATE.md')
this.destinationPath('.github/pull_request_template.md')
)
// Git-flex
this.fs.copyTpl(
Expand All @@ -778,7 +790,8 @@ module.exports = class extends Generator {
author: this.props.author,
license: this.props.license[0],
badge: this.props.license[1],
badgelink: this.props.license[2]
badgelink: this.props.license[2],
ci: this.props.ci
})
this.fs.copyTpl(
this.templatePath('github/contributing.md'),
Expand All @@ -787,7 +800,7 @@ module.exports = class extends Generator {
})
this.fs.copyTpl(
this.templatePath('github/ISSUE_TEMPLATE.md'),
this.destinationPath('.github/ISSUE_TEMPLATE.md'), {
this.destinationPath('.github/ISSUE_TEMPLATE/bug_report.md'), {
title: this.props.title
})
// insert responses into pkgJson
Expand Down Expand Up @@ -828,15 +841,25 @@ module.exports = class extends Generator {
})
}

// no prompt
// CI, mocha, cypress testing (no prompts)
this.fs.copyTpl(
this.templatePath('ci/.travis.yml'),
this.destinationPath('.travis.yml'), {
apptype: this.props.apptype[0]
}
)
// CI
switch (this.props.ci) {
case 'travis':
this.fs.copyTpl(
this.templatePath('ci/.travis.yml'),
this.destinationPath('.travis.yml'), {
apptype: this.props.apptype[1]
})
break
default:
this.fs.copyTpl(
this.templatePath('ci/exist.yml'),
this.destinationPath('.github/workflows/exist.yml'), {
apptype: this.props.apptype[1]
}
)
}

// no prompt
// TODO these will need to be adapted for polymer apps
// Mocha
this.fs.copy(
Expand Down Expand Up @@ -900,7 +923,7 @@ module.exports = class extends Generator {
})

Object.assign(pkgJson.scripts, {
cypress: 'cypress open'
cypress: 'cypress run'
})
}
break
Expand Down
2 changes: 1 addition & 1 deletion generators/app/templates/ci/.travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ before_script:

script:
- npm test
<%_ if (apptype == 'exist-design' || apptype == 'plain' || apptype == 'empty') { %> - cypress run<% } -%>
<%_ if (apptype != 'library') { %> - cypress run<% } -%>

# - ant test

Expand Down
108 changes: 108 additions & 0 deletions generators/app/templates/ci/exist.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
# This workflow builds a xar archive, deploys it into exist and execute its test suites.
# It also includes code for using semantic-release to upload packages as part of GitHub releases
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: exist-db CI

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
exist-version: [latest, release]
java-version: [8]
node-version: [12.x, 14.x]
# TODO: see #563 could still be usefull for gulp builds
# services:
# # Label used to access the service container
# exist:
# image: existdb/existdb:${{ matrix.exist-version}}
# ports:
# - 8080:8080

steps:
# Checkout code
- uses: actions/checkout@v2
# set-up caches
- name: Cache node modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
# Build Frontend
- name: Build Frontend Using Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm ci

# Build Expath Package
# TODO: #563 make optional for gulp builds
- name: Build Expath Package
uses: actions/setup-java@v1
with:
java-version: ${{ matrix.java-version }}
- run: ant

# Deploy Package in Container
- name: Pull Base Image
run: docker pull existdb/existdb:${{ matrix.exist-version }}

- name: Create CI Container
run: docker create --name exist-ci -p 8080:8080 existdb/existdb:${{ matrix.exist-version }}

- name: Prep CI Container
run: docker cp ./build/*-dev.xar exist-ci:exist/autodeploy

- name: Start Exist Container
run: docker start exist-ci && sleep 30

# Testing
- name: Run Unit Tests
run: npm test
<%_ if (apptype != 'library') { %>
- name: Run Integration Tests
run: npm run cypress
<% } -%>
# TODO: Add upload to dockerhub
# release:
# name: Release
# runs-on: ubuntu-latest
# needs: build
# if: github.ref == 'refs/heads/master'
# steps:
# - name: Checkout
# uses: actions/checkout@v2
# with:
# fetch-depth: 0
# - name: Setup Node.js
# uses: actions/setup-node@v1
# with:
# node-version: 14
# - name: Install dependencies
# run: npm ci
# - name: Create package
# run: npm run build
# - name: Release
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# run: npx semantic-release


9 changes: 9 additions & 0 deletions generators/app/templates/github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
---
name: Bug report
about: Create a report to help us improve
title: "[BUG]"
labels: ''
assignees: ''

---

### Expected behavior

### Actual behavior
Expand Down
7 changes: 4 additions & 3 deletions generators/app/templates/github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
### Thank you for your Pull Request

If you're adding a new feature, please adjust / add tests covering your code changes. You can reference any related issues below.

Fixes #
---
- [ ] includes changes to documentation / readme
- [ ] did you already increase version number according to [sem-ver](http://semver.org)?
14 changes: 14 additions & 0 deletions generators/app/templates/github/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
name: Feature request
about: Suggest an idea
title: ''
labels: enhancement
assignees: ''

---

### Your Ideal Solution

### Any Alternative Options

### Additional Context
21 changes: 11 additions & 10 deletions generators/app/templates/github/readme.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
# <%- title %>
[![License][license-img]][license-url]
[![GitHub release][release-img]][release-url]
[![NPM version][npm-image]][npm-url]
<%_ if (ci == 'travis') { -%>
[![Build Status][travis-image]][travis-url]
[![Dependency Status][daviddm-image]][daviddm-url]
<%_ } else { _%>
![exist-db CI](https://github.com/<%- ghuser %>/<%- title %>/workflows/exist-db%20CI/badge.svg)
<% } -%>
[![Coverage percentage][coveralls-image]][coveralls-url]

<img src="icon.png" align="left" width="25%"/>

<%- desc %>

## Requirements
* [exist-db](http://exist-db.org/exist/apps/homepage/index.html) version: `5.0.0` or greater
* [exist-db](http://exist-db.org/exist/apps/homepage/index.html) version: `5.x` or greater

* [ant](http://ant.apache.org) version: `1.10.7` \(for building from source\)
<%_ if (apptype == 'exist-design' || 'plain') { %>
* [node](http://nodejs.org) version: `10.0.0` \(for building from source\)
<% } -%>
<% if (apptype == 'exist-design' || 'plain') { %>
* [node](http://nodejs.org) version: `12.x` \(for building from source\)
<% } %>

## Installation
1. Download the `<%- title %>-<%- version %>.xar` file from GitHub [releases](https://github.com/<%- ghuser %>/<%- title %>/releases) page.
Expand Down Expand Up @@ -111,11 +114,9 @@ You can take a look at the [Contribution guidelines for this project](.github/CO
[license-url]: <%- badgelink %>
[release-img]: https://img.shields.io/badge/release-<%- version %>-green.svg
[release-url]: https://github.com/<%- ghuser %>/<%- title %>/releases/latest
[npm-image]: https://badge.fury.io/js/<%- title %>.svg
[npm-url]: https://npmjs.org/package/<%- title %>
<%_ if (ci == 'travis') { %>
[travis-image]: https://travis-ci.com/<%- ghuser %>/<%- title %>.svg?branch=master
[travis-url]: https://travis-ci.com/<%- ghuser %>/<%- title %>
[daviddm-image]: https://david-dm.org/<%- ghuser %>/<%- title %>.svg?theme=shields.io
[daviddm-url]: https://david-dm.org/<%- ghuser %>/<%- title %>
<% } -%>
[coveralls-image]: https://coveralls.io/repos/<%- ghuser %>/<%- title %>/badge.svg
[coveralls-url]: https://coveralls.io/r/<%- ghuser %>/<%- title %>
Loading

0 comments on commit fd3d2aa

Please sign in to comment.