Skip to content

Commit 40d3152

Browse files
authored
Merge pull request #584 from CaptainFact/test/github-ci
Migrate to Github CI
2 parents d4550e5 + ccff050 commit 40d3152

File tree

8 files changed

+135
-71
lines changed

8 files changed

+135
-71
lines changed

.github/workflows/ci.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: CI
2+
3+
on: [push]
4+
5+
jobs:
6+
lint:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v1
10+
- uses: actions/setup-node@v1
11+
- name: Restore node_modules
12+
uses: actions/cache@v1
13+
id: node-modules
14+
with:
15+
path: node_modules
16+
key: ${{ runner.os }}-node-modules-${{ hashFiles('package-lock.json') }}
17+
- name: Restore .npm cache
18+
if: steps.node-modules.outputs.cache-hit != 'true'
19+
uses: actions/cache@v1
20+
with:
21+
path: ~/.npm
22+
key: ${{ runner.os }}-npm-cache-${{ hashFiles('package-lock.json') }}
23+
restore-keys: |
24+
${{ runner.os }}-npm-cache-${{ hashFiles('package-lock.json') }}
25+
${{ runner.os }}-npm-cache-
26+
27+
- name: Install dependencies
28+
if: steps.node-modules.outputs.cache-hit != 'true'
29+
run: CYPRESS_INSTALL_BINARY=0 npm ci --prefer-offline --no-audit
30+
- run: npm run lint
31+
32+
test:
33+
name: Unit tests
34+
runs-on: ubuntu-latest
35+
steps:
36+
- uses: actions/checkout@v1
37+
- uses: actions/setup-node@v1
38+
- name: Restore node_modules
39+
uses: actions/cache@v1
40+
id: node-modules
41+
with:
42+
path: node_modules
43+
key: ${{ runner.os }}-node-modules-${{ hashFiles('package-lock.json') }}
44+
- name: Restore .npm cache
45+
if: steps.node-modules.outputs.cache-hit != 'true'
46+
uses: actions/cache@v1
47+
with:
48+
path: ~/.npm
49+
key: ${{ runner.os }}-npm-cache-${{ hashFiles('package-lock.json') }}
50+
restore-keys: |
51+
${{ runner.os }}-npm-cache-${{ hashFiles('package-lock.json') }}
52+
${{ runner.os }}-npm-cache-
53+
- name: Install dependencies
54+
if: steps.node-modules.outputs.cache-hit != 'true'
55+
run: CYPRESS_INSTALL_BINARY=0 npm ci --prefer-offline --no-audit
56+
- name: Run tests
57+
run: npm run coverage
58+
- name: Post tests coverage
59+
uses: coverallsapp/github-action@master
60+
with:
61+
github-token: ${{ secrets.GITHUB_TOKEN }}
62+
path-to-lcov: ./coverage/lcov.info

.github/workflows/e2e.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: E2E/Integration tests
2+
3+
on: [push]
4+
5+
env:
6+
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
7+
8+
jobs:
9+
cypress:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v1
13+
- uses: actions/setup-node@v1
14+
- name: Restore node_modules
15+
uses: actions/cache@v1
16+
id: node-modules
17+
with:
18+
path: node_modules
19+
key: ${{ runner.os }}-node-modules-${{ hashFiles('package-lock.json') }}
20+
- name: Restore .npm cache
21+
if: steps.node-modules.outputs.cache-hit != 'true'
22+
uses: actions/cache@v1
23+
with:
24+
path: ~/.npm
25+
key: ${{ runner.os }}-npm-cache-${{ hashFiles('package-lock.json') }}
26+
restore-keys: |
27+
${{ runner.os }}-npm-cache-${{ hashFiles('package-lock.json') }}
28+
${{ runner.os }}-npm-cache-
29+
- name: Install dependencies
30+
if: steps.node-modules.outputs.cache-hit != 'true'
31+
run: CYPRESS_INSTALL_BINARY=0 npm ci --prefer-offline --no-audit
32+
- name: Start local API
33+
run: docker-compose up -d
34+
- name: Start Frontend
35+
run: npm start &
36+
- name: Waiting for Frontend to be ready
37+
run: until curl -s localhost:3333 > /dev/null; do sleep 1; done
38+
- name: Waiting for API to be ready
39+
run: until curl localhost:4000; do sleep 1; done
40+
- name: Run tests
41+
run: npm run cypress -- --record
42+
- name: Shutdown Frontend
43+
run: kill $(jobs -p) || true
44+
- name: Shutdown API
45+
run: docker-compose down

.github/workflows/release.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- staging
8+
9+
env:
10+
CF_FRONTEND_IMAGE: captainfact/frontend:${{ GITHUB_REF }}
11+
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
12+
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
13+
14+
jobs:
15+
push-to-docker-hub:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v1
19+
- run: docker build --build-arg BUILD_ENV=${{ GITHUB_REF }} -t $CF_FRONTEND_IMAGE .
20+
- run: docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD"
21+
- run: docker push $CF_FRONTEND_IMAGE

.travis.yml

Lines changed: 0 additions & 51 deletions
This file was deleted.

app/components/Speakers/AddSpeakerForm.jsx

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { connect } from 'react-redux'
33
import { withNamespaces } from 'react-i18next'
44
import AsyncCreatable from 'react-select/lib/AsyncCreatable'
55
import debounce from 'debounce-promise'
6-
import theme from '../../styles/theme'
76

87
import { checkLength } from '../../lib/form_validators'
98
import { SocketApi } from '../../API'
@@ -14,20 +13,17 @@ import { cleanStr } from '../../lib/clean_str'
1413
import Container from '../StyledUtils/Container'
1514
import { ReactSelectStyles, ReactSelectTheme } from '../../lib/react_select_theme'
1615

17-
@connect(
18-
null,
19-
{ addSpeaker }
20-
)
16+
@connect(null, { addSpeaker })
2117
@withNamespaces('videoDebate')
2218
export default class AddSpeakerForm extends React.PureComponent {
2319
searchSpeakerRequest = debounce(query => {
2420
return query.length < 3
2521
? []
2622
: SocketApi.push('video_debate', 'search_speaker', { query }).then(
27-
({ speakers }) => {
28-
return speakers.map(s => ({ label: s.full_name, value: s }))
29-
}
30-
)
23+
({ speakers }) => {
24+
return speakers.map(s => ({ label: s.full_name, value: s }))
25+
}
26+
)
3127
}, 250)
3228

3329
promptTextCreator = speakerName => {
@@ -37,7 +33,7 @@ export default class AddSpeakerForm extends React.PureComponent {
3733
}
3834

3935
onChange = ({ value }, { action }) => {
40-
const { addSpeaker, reset } = this.props
36+
const { addSpeaker } = this.props
4137

4238
if (action === 'select-option' && value && value.id) {
4339
addSpeaker(value)

app/lib/form_validators.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import capitalize from 'voca/capitalize'
2-
31
export const checkLength = (value, range) => {
42
return (
53
value && value.length >= range[0] && (range[1] === -1 || value.length <= range[1])

app/state/video_debate/effects.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { SocketApi } from '../../API'
22
import { VIDEO_DEBATE_CHANNEL } from '../../constants'
33
import { presenceDiff, setPresence } from './presence/reducer'
44
import * as videoReducer from './video/reducer'
5-
import { errorToFlash, errorMsgToFlash } from '../flashes/reducer'
5+
import { errorToFlash } from '../flashes/reducer'
66
import { createEffect, generateFSAError } from '../utils'
77

88
export const joinVideoDebateChannel = videoId => dispatch => {

package.json

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,6 @@
4242
"cypress"
4343
]
4444
},
45-
"lint-staged": {
46-
"app/**/*.{js,jsx}": [
47-
"npx prettier --write",
48-
"git add",
49-
"npx eslint --fix"
50-
]
51-
},
5245
"browserslist": {
5346
"production": [
5447
"> 2%",

0 commit comments

Comments
 (0)