Skip to content

Commit

Permalink
CI(GA): Add github actions for CI (#296)
Browse files Browse the repository at this point in the history
* Create nodejs.yml

* update for use github actions

* add some test

* ci(githubactions): add github acctions for CI

* refactor(husky): create new script for use start-server-and-test

* CI(gh): change script

* CI(gh): change script for e2e

* CI(gh): add status badge

* CI(gh): add status badge

* Update sampleBlog.spec.js
  • Loading branch information
jorgeucano authored Feb 14, 2020
1 parent 6dd42a5 commit a177a30
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 10 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Node.js CI

on: [push]

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [12.x]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm install
- run: npm run scully:compile:all
- run: node ./dist/scully/scully --tds --host='0.0.0.0'
- run: npm run test
- run: npm run e2e:full
env:
CI: true
2 changes: 1 addition & 1 deletion .huskyrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"hooks": {
"pre-commit": "pretty-quick --staged",
"pre-push": "npm run scully:precommit && start-server-and-test scully:r http://localhost:1668 e2e"
"pre-push": "npm run scully:precommit && npm run e2e:full"
}
}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
[![Gitter](https://img.shields.io/gitter/room/scullyio/community)](https://gitter.im/scullyio/community)
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
[![CLA assistant](https://cla-assistant.io/readme/badge/scullyio/scully)](https://cla-assistant.io/scullyio/scully)
![Node.js CI](https://github.com/scullyio/scully/workflows/Node.js%20CI/badge.svg)

The best way to build the fastest Angular apps. Scully is a static site generator for Angular projects looking to embrace the JAMStack.

Expand Down
10 changes: 3 additions & 7 deletions cypress/integration/sampleBlog.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,9 @@ context('check first integration test', () => {
});
});

it('Check the list of users after navigation', () => {
cy.visit('/home');
cy.get('ul>li>a')
.contains('/user')
.click()
.get('a')
.contains('Leanne Graham');
it('Check the list of users', () => {
cy.visit('/user');
cy.get('a').contains('Leanne Graham');
});

it('Check is transferState exist in html', () => {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"test": "jest",
"test:watch": "jest --watch",
"e2e": "cypress run --spec 'cypress/integration/**/*' --browser chrome",
"e2e:full": "start-server-and-test scully:r http://localhost:1668 e2e",
"tsc": "tsc",
"scully:run": "npm run scully:dev:all -- serve",
"scully:run:test": "npm run test && npm run e2e",
Expand Down
5 changes: 4 additions & 1 deletion scully/scully.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {logError, logWarn, yellow} from './utils/log';
import {startScully} from './utils/startup';
import {waitForServerToBeAvailable} from './utils/waitForServerToBeAvailable';
import {bootServe, isBuildThere, watchMode} from './watchMode';
import {watch, removeStaticDist, openNavigator} from './utils/cli-options';
import {watch, removeStaticDist, openNavigator, hostName} from './utils/cli-options';
const open = require('open');

/** the default of 10 is too shallow for generating pages. */
Expand All @@ -30,6 +30,9 @@ if (process.argv.includes('version')) {
(async () => {
/** make sure not to do something before the config is ready */
const scullyConfig = await loadConfig;
if (hostName) {
scullyConfig.hostName = hostName;
}
if (process.argv.includes('killServer')) {
await httpGetJson(`http://${scullyConfig.hostName}:${scullyConfig.appPort}/killMe`, {
suppressErrors: true,
Expand Down
6 changes: 6 additions & 0 deletions scully/utils/cli-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,9 @@ export const {proxyConfigFile} = yargs
.alias('proxy', 'proxyConfigFile')
.alias('proxy', 'proxyConfig')
.describe('proxy', 'Load proxy config from file').argv;

export const {hostName} = yargs
.string('hostName')
.default('hostName', undefined)
.alias('host', 'hostName')
.describe('host', 'Add hostname for scully').argv;
2 changes: 1 addition & 1 deletion src/__tests__/transfer-state.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {readFileSync} from 'fs';
import {join} from 'path';
import {extractTransferState, replaceIndexNG} from '../test-config.helper';
import {cl, extractTransferState, replaceIndexNG} from '../test-config.helper';

describe('TransferState', () => {
it('should add state to page 1', () => {
Expand Down
5 changes: 5 additions & 0 deletions src/test-config.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export const separateTransferFromHtml = index => {
if (index.indexOf(SCULLY_STATE_START) === -1) {
return [index, null];
}

// Remove transfer state
const [start, remaining] = index.split(SCULLY_STATE_START);
const [transferStateBlob, end] = remaining.split(SCULLY_STATE_END);
Expand All @@ -48,3 +49,7 @@ export const separateTransferFromHtml = index => {

return [indexWithoutTransferState, transferState];
};

export const cl = (something: string) => {
console.log(something);
};

0 comments on commit a177a30

Please sign in to comment.