Skip to content

Commit fd034a7

Browse files
authored
Setup GitHub actions to run CI/CD (#104)
* ci: add github actions yaml config file * ci: add stub Cypress test so it does not fail * ci: change ie browserlist entry causing Cypress e2e tests to fail * test: add explicit cypress component test command to tests action * ci: add npm install command to explicitly install peer dependencies * ci: move vue to a dev dependecy so it is always installed npm v6 does not automatically install peer dependencies * ci: fix path to cypress alias of vue and reduce GH action env's until fully setup * chore: update git emojis and remove `wip` type * docs: add docs in readme file about testing GH actions locally * style: switch GH actions yaml config to use yaml array syntax ISSUES CLOSED: #100
1 parent 919a849 commit fd034a7

File tree

11 files changed

+158
-39
lines changed

11 files changed

+158
-39
lines changed

.browserslistrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
last 2 versions
33
Firefox ESR
44
not dead
5-
not ie
5+
not ie >= 0

.cz-config.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module.exports = {
44
types: [
55
{ value: 'feat', name: '✨ feat: A new feature' },
66
{ value: 'fix', name: '🐛 fix: A bug fix' },
7-
{ value: 'docs', name: '📝 docs: Documentation only changes' },
7+
{ value: 'docs', name: '📚 docs: Documentation only changes' },
88
{
99
value: 'style',
1010
name: '🎨 style: Changes that do not affect the meaning of the code\n(white-space, formatting, missing semi-colons, etc)',
@@ -15,15 +15,15 @@ module.exports = {
1515
},
1616
{
1717
value: 'perf',
18-
name: ' perf: A code change that improves performance',
18+
name: '🚀 perf: A code change that improves performance',
1919
},
2020
{
2121
value: 'test',
2222
name: '✅ test: Adding missing tests or stories (example scopes: Cypress, Storybook)',
2323
},
2424
{
2525
value: 'build',
26-
name: '🔨 build: Changes that affect the build system or external dependencies (example scopes: Vite, npm, hygen)',
26+
name: '🛠 build: Changes that affect the build system or external dependencies (example scopes: Vite, npm, hygen)',
2727
},
2828
{
2929
value: 'ci',
@@ -33,8 +33,7 @@ module.exports = {
3333
value: 'chore',
3434
name: '👷 chore: Changes to the build process or auxiliary tools\nand libraries such as documentation generation',
3535
},
36-
{ value: 'revert', name: '⏪ revert: Reverts a previous commit' },
37-
{ value: 'WIP', name: '🚧 WIP: Work in progress' },
36+
{ value: 'revert', name: '🗑 revert: Reverts a previous commit' },
3837
],
3938

4039
// override the messages, defaults are as follows

.github/workflows/tests.yml

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Tests
2+
3+
on:
4+
- push
5+
- pull_request
6+
7+
jobs:
8+
# This job lints all files with ESLint.
9+
lint:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v2
13+
14+
- name: Setup node
15+
uses: actions/setup-node@v2
16+
with:
17+
node-version: 14
18+
cache: 'npm'
19+
20+
- name: Install dependencies
21+
run: npm ci
22+
23+
- name: Lint files
24+
run: npm run lint
25+
26+
# This job runs all Cypress tests.
27+
cypress-test:
28+
runs-on: ${{ matrix.os }}
29+
30+
strategy:
31+
matrix:
32+
os:
33+
- ubuntu-latest
34+
# TODO: Re-enable once a public release of the library is available.
35+
# Mac and windows env's take significantly longer to run.
36+
# - macos-latest
37+
# - windows-latest
38+
node:
39+
- 14
40+
- 16
41+
42+
steps:
43+
- uses: actions/checkout@v2
44+
45+
- name: Use Node.js ${{ matrix.node-version }}
46+
uses: actions/setup-node@v2
47+
with:
48+
node-version: ${{ matrix.node-version }}
49+
50+
- name: E2E tests on Node v${{ matrix.node }}
51+
uses: cypress-io/github-action@v2
52+
with:
53+
command: npm run test:e2e
54+
55+
- name: Component tests on Node v${{ matrix.node }}
56+
uses: cypress-io/github-action@v2
57+
with:
58+
# We have already installed everything.
59+
install: false
60+
command: npm run test:component

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ dist-ssr
88
cypress/examples
99
cypress/videos
1010
cypress/screenshots
11+
cypress/downloads
1112

1213
# Storybook artifacts.
1314
.storybook/examples

README.md

+15
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,18 @@ A Vue 3 implementation of the [USWDS](https://designsystem.digital.gov).
66

77
- [VSCode](https://code.visualstudio.com)
88
- [Volar](https://marketplace.visualstudio.com/items?itemName=johnsoncodehk.volar)
9+
10+
## Testing Github Actions Locally
11+
12+
Use [act](https://github.com/nektos/act) to test Github actions locally.
13+
14+
**Note:** Because the [act](https://github.com/nektos/act) docker containers do not have the XVFB dependency installed, you must use a custom docker container from Cypress by adding:
15+
16+
```yaml
17+
container:
18+
image: cypress/browsers:node14.17.0-chrome91-ff89
19+
```
20+
21+
The specific container can be one of [Cypress's docker images](https://github.com/cypress-io/cypress-docker-images).
22+
23+
You may also need to temporarily adjust the node matrix versions to use the provided by the Cypress container.

cypress.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"video": false,
23
"component": {
34
"componentFolder": "src/components",
45
"testFiles": "**/*.test.js"

cypress/integration/init.test.js

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
describe('cypress runs', () => {
2+
it('cypress does not fail because of no test files in integration folder', () => {
3+
expect(true).to.equal(true)
4+
})
5+
})

cypress/plugins/index.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,15 @@ module.exports = (on, config) => {
2828
configFile: path.resolve(__dirname, '..', '..', 'vite.config.js'),
2929
resolve: {
3030
alias: {
31-
vue: 'vue/dist/vue.esm-bundler.js',
31+
vue: path.resolve(
32+
__dirname,
33+
'..',
34+
'..',
35+
'node_modules',
36+
'vue',
37+
'dist',
38+
'vue.esm-bundler.js'
39+
),
3240
},
3341
},
3442
}

cypress/support/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
// ***********************************************************
1515

1616
// Import commands.js using ES2015 syntax:
17-
import './commands'
17+
import './commands.js'
1818

1919
// Alternatively you can use CommonJS syntax:
2020
// require('./commands')

0 commit comments

Comments
 (0)