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

CI build and Unit Test #20

Merged
merged 9 commits into from
Mar 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
22 changes: 22 additions & 0 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# This workflow will do a clean install of node dependencies and run tests on node version 8.x

name: Affirmations CI

on:
pull_request:
branches: [ master ]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: actions/setup-node@v1
with:
node-version: '8.x'
- name: Installing dependencies
run: npm
- name: Running tests
run: npm test
env:
CI: true
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules/
coverage/
.DS_Store
3 changes: 1 addition & 2 deletions affirmations.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,4 @@ const affirmations = [
"It's not a mistake, it's a learning opportunity",
];

const getRandomAffirmation = () => affirmations[Math.floor(Math.random() * affirmations.length)];
module.exports = getRandomAffirmation;
module.exports = affirmations
14 changes: 5 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
const http = require('http');
const express = require('express');
const getRandomAffirmation = require('./affirmations');
const getRandomAffirmation = require('./random_affirmation');

const app = express();

let port = process.env.PORT;
if (port == null || port == "") {
port = 3000;
}
let PORT = process.env.PORT || 3000;

app.get('/', (req, res) => {
res.json({affirmation: getRandomAffirmation()});
});

http.createServer(app).listen(port, () => {
console.log(`express server listening on port ${port}`);
});
const server = app.listen(PORT, () => console.log(`Server is live at localhost:${PORT}`));

module.exports = server;
Loading