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

[FEATURE-36] Create CI/CD pipeline with build-deploy steps #36

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
50 changes: 50 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# editorconfig.org

; top-most EditorConfig file
root = true

; define basic and global for any file
[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
max_line_length = off
trim_trailing_whitespace = true
curly_bracket_next_line = false
spaces_around_operators = true

; DOS/Windows batch scripts -
[*.{bat,cmd}]
end_of_line = crlf

; JavaScript files -
[*.{js,ts}]
curly_bracket_next_line = true
indent_size = 2
quote_type = double

; JSON files (normal and commented version) -
[*.{json,jsonc}]
indent_size = 2
quote_type = double

; Make - match it own default syntax
[Makefile]
indent_style = tab

; Markdown files - preserve trail spaces that means break line
[*.{md,markdown}]
trim_trailing_whitespace = false

; PowerShell - match defaults for New-ModuleManifest and PSScriptAnalyzer Invoke-Formatter
[*.{ps1,psd1,psm1}]
charset = utf-8-bom
end_of_line = crlf

; YML config files - match it own default syntax
[*.{yaml,yml}]
indent_size = 2
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
build/
node_modules/
fpb.json
148 changes: 148 additions & 0 deletions .github/workflows/webapp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
name: "CI-CD: free-programming-books-search"

on: # This pipeline is executed when:
push: # - A push event is fired
branches: # over this branches
- main
pull_request: # - A pull request
branches: # over this base branches
- main
types: # is...
- opened # submitted
- synchronize # or push more commits
- reopened # or reopened after closed (no merged)

permissions:
# needed to checkouts/branching
contents: read

# This allows a subsequently queued workflow run to interrupt/wait for previous runs
concurrency:
group: '${{ github.workflow }}'
cancel-in-progress: true # true: interrupt, false = wait for

jobs:

lint:
runs-on: ubuntu-latest
steps:
- name: Checkout project
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 16
cache: 'npm'
- name: Install dependencies
run: |
npm ci
- name: Run code linter
run: |
npm run lint

build:
runs-on: ubuntu-latest
steps:
- name: Checkout project
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 16
cache: 'npm'
- name: Install dependencies
run: |
npm ci
- name: Run webapp builder
run: |
npm run build
- name: Upload build artifact
uses: actions/upload-artifact@v3
with:
name: build
path: build

# Testcases with Jest
test:
needs: [lint, build]
runs-on: ubuntu-latest
steps:
- name: Checkout project
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 16
cache: 'npm'
- name: Install dependencies
run: |
npm ci
- name: Download build artifact
uses: actions/download-artifact@v3
with:
name: build
path: build
- name: Run tests
run: npm test


# Tests E2E with Cypress
e2e:
needs: [lint, build]
runs-on: ubuntu-latest
steps:
- name: Checkout project
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 16
cache: 'npm'
- name: Install dependencies
run: |
npm ci
- name: Download build artifact
uses: actions/download-artifact@v3
with:
name: build
path: build
- name: Run E2E tests
# TODO: Enable again after configure Cypress test environment
if: ${{ false }}
run: npm run test:e2e

deploy:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can use GitHub deploy pages action here.

needs: [test, e2e]
permissions:
# needs branching/commit contents
contents: write
runs-on: ubuntu-latest
steps:
- name: Checkout project
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Download build artifact
uses: actions/download-artifact@v3
with:
name: build
path: build
- name: Deploy to GitHub Pages
uses: JamesIves/github-pages-deploy-action@v4
with:
token: ${{ github.token }}
# The branch the action should deploy.
branch: gh-pages
# The folder the action should deploy.
folder: build
# Test git push mode??
dry-run: ${{ github.event_name == 'pull_request' }}

114 changes: 101 additions & 13 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading