Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

feat: add GitHub Action out-of-the-box #621

Merged
merged 18 commits into from
Oct 5, 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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ yarn create nuxt-app <my-project>
- [jsconfig.json](https://code.visualstudio.com/docs/languages/jsconfig)
- [Semantic PR](https://probot.github.io/apps/semantic-pull-requests/)
- [Dependabot (for GitHub only)](https://dependabot.com/)
1. Continous Integration
- [GitHub Actions](https://github.com/features/actions)

## CLI Options

Expand Down
24 changes: 20 additions & 4 deletions packages/cna-template/template/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,34 @@
version: 2
updates:
# Fetch and update latest `npm` packages
- package-ecosystem: npm
directory: "/"
directory: '/'
schedule:
interval: daily
time: '00:00'
open-pull-requests-limit: 99
open-pull-requests-limit: 10
reviewers:
- <%= gitUsername %>
assignees:
- <%= gitUsername %>
labels:
- dependencies
commit-message:
prefix: fix
prefix-development: chore
include: scope
<%_ if (ci === 'github-actions') { _%>
# Fetch and update latest `github-actions` pkgs
- package-ecosystem: github-actions
directory: '/'
schedule:
interval: daily
time: '00:00'
open-pull-requests-limit: 10
reviewers:
- <%= gitUsername %>
assignees:
- <%= gitUsername %>
commit-message:
prefix: fix
prefix-development: chore
include: scope
<%_ } _%>
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: ci

on:
push:
branches:
- main
- master
pull_request:
branches:
- main
- master

jobs:
ci:
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ubuntu-latest]
node: [14]

steps:
- name: Checkout 🛎
uses: actions/checkout@master

- name: Setup node env 🏗
uses: actions/[email protected]
with:
node-version: ${{ matrix.node }}

<%_ if (pm === 'yarn') { _%>
- name: Get yarn cache directory path 🛠
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- name: Cache node_modules 📦
uses: actions/cache@v2
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
<%_ } _%>
<%_ if (pm === 'npm') { _%>
- name: Cache node_modules 📦
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
<%_ } _%>

- name: Install dependencies 👨🏻‍💻
run: <%= pmRun === 'yarn' ? 'yarn' : 'npm ci' %>

<%_ if (linter.length > 0) { _%>
- name: Run linter 👀
run: <%= pmRun %> lint
<%_ } _%>

<%_ if (test !== 'none') { _%>
- name: Run tests 🧪
run: <%= pmRun %> test
<%_ } _%>
13 changes: 12 additions & 1 deletion packages/create-nuxt-app/lib/prompts.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,18 @@ module.exports = [
default: []
},
{
when: answers => answers.devTools.includes('dependabot'),
when: ({ test, linter }) => test !== 'none' || linter.length > 0,
name: 'ci',
message: 'Continuous integration:',
type: 'list',
choices: [
{ name: 'None', value: 'none' },
{ name: 'GitHub Actions (GitHub only)', value: 'github-actions' }
],
default: 'none'
},
{
when: ({ devTools, ci }) => devTools.includes('dependabot') || ci !== 'none',
name: 'gitUsername',
message: 'What is your GitHub username?',
default: '{gitUser.name}',
Expand Down
8 changes: 8 additions & 0 deletions packages/create-nuxt-app/lib/saofile.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ module.exports = {
})
}

if (this.answers.ci && this.answers.ci !== 'none') {
actions.push({
type: 'add',
files: '**',
templateDir: join(frameworksDir, this.answers.ci)
})
}

actions.push({
type: 'add',
files: '*',
Expand Down
164 changes: 164 additions & 0 deletions packages/create-nuxt-app/test/snapshots/index.test.js.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,170 @@ The actual snapshot is saved in `index.test.js.snap`.

Generated by [AVA](https://avajs.dev).

## verify ci: GitHub Actions (GitHub only)

> Generated files

[
'.editorconfig',
'.gitignore',
'README.md',
'assets/README.md',
'components/Logo.vue',
'components/README.md',
'layouts/README.md',
'layouts/default.vue',
'middleware/README.md',
'nuxt.config.js',
'package.json',
'pages/README.md',
'pages/index.vue',
'plugins/README.md',
'static/README.md',
'static/favicon.ico',
'store/README.md',
]

> package.json

{
dependencies: {
'core-js': '^3.6.5',
nuxt: '^2.14.6',
},
devDependencies: {},
private: true,
scripts: {
build: 'nuxt build',
dev: 'nuxt',
generate: 'nuxt generate',
start: 'nuxt start',
},
}

> Generated nuxt.config.js

`export default {␊
// Global page headers (https://go.nuxtjs.dev/config-head)␊
head: {␊
title: 'output',␊
meta: [␊
{ charset: 'utf-8' },␊
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },␊
{ hid: 'description', name: 'description', content: '' }␊
],␊
link: [␊
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }␊
]␊
},␊
// Global CSS (https://go.nuxtjs.dev/config-css)␊
css: [␊
],␊
// Plugins to run before rendering page (https://go.nuxtjs.dev/config-plugins)␊
plugins: [␊
],␊
// Auto import components (https://go.nuxtjs.dev/config-components)␊
components: true,␊
// Modules for dev and build (recommended) (https://go.nuxtjs.dev/config-modules)␊
buildModules: [␊
],␊
// Modules (https://go.nuxtjs.dev/config-modules)␊
modules: [␊
],␊
// Build Configuration (https://go.nuxtjs.dev/config-build)␊
build: {␊
}␊
}␊
`

## verify ci: None

> Generated files

[
'.editorconfig',
'.gitignore',
'README.md',
'assets/README.md',
'components/Logo.vue',
'components/README.md',
'layouts/README.md',
'layouts/default.vue',
'middleware/README.md',
'nuxt.config.js',
'package.json',
'pages/README.md',
'pages/index.vue',
'plugins/README.md',
'static/README.md',
'static/favicon.ico',
'store/README.md',
]

> package.json

{
dependencies: {
'core-js': '^3.6.5',
nuxt: '^2.14.6',
},
devDependencies: {},
private: true,
scripts: {
build: 'nuxt build',
dev: 'nuxt',
generate: 'nuxt generate',
start: 'nuxt start',
},
}

> Generated nuxt.config.js

`export default {␊
// Global page headers (https://go.nuxtjs.dev/config-head)␊
head: {␊
title: 'output',␊
meta: [␊
{ charset: 'utf-8' },␊
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },␊
{ hid: 'description', name: 'description', content: '' }␊
],␊
link: [␊
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }␊
]␊
},␊
// Global CSS (https://go.nuxtjs.dev/config-css)␊
css: [␊
],␊
// Plugins to run before rendering page (https://go.nuxtjs.dev/config-plugins)␊
plugins: [␊
],␊
// Auto import components (https://go.nuxtjs.dev/config-components)␊
components: true,␊
// Modules for dev and build (recommended) (https://go.nuxtjs.dev/config-modules)␊
buildModules: [␊
],␊
// Modules (https://go.nuxtjs.dev/config-modules)␊
modules: [␊
],␊
// Build Configuration (https://go.nuxtjs.dev/config-build)␊
build: {␊
}␊
}␊
`

## verify default answers

> Generated files
Expand Down
Binary file modified packages/create-nuxt-app/test/snapshots/index.test.js.snap
Binary file not shown.