Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
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
78 changes: 42 additions & 36 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,49 +1,55 @@
/* eslint-env node */
module.exports = {
"env": {
"browser": true,
"es6": true,
"jest/globals": true
'env': {
'browser': true,
'es6': true,
'jest/globals': true
},
"extends": [
"eslint:recommended",
"plugin:react/recommended"
'extends': [
'eslint:recommended',
'plugin:react/recommended'
],
"parserOptions": {
"ecmaFeatures": {
"jsx": true
'parserOptions': {
'ecmaFeatures': {
'jsx': true
},
"ecmaVersion": 2018,
"sourceType": "module"
'ecmaVersion': 2018,
'sourceType': 'module'
},
"plugins": [
"react", "jest"
'plugins': [
'react', 'jest'
],
"rules": {
"indent": [
"error",
2
],
"linebreak-style": [
"error",
"unix"
'rules': {
'indent': [
'error',
2
],
"quotes": [
"error",
"single"
'linebreak-style': [
'error',
'unix'
],
"semi": [
"error",
"never"
'quotes': [
'error',
'single'
],
"eqeqeq": "error",
"no-trailing-spaces": "error",
"object-curly-spacing": [
"error", "always"
'semi': [
'error',
'never'
],
"arrow-spacing": [
"error", { "before": true, "after": true }
'eqeqeq': 'error',
'no-trailing-spaces': 'error',
'object-curly-spacing': [
'error', 'always'
],
"no-console": "error",
"react/prop-types": 0
'arrow-spacing': [
'error', { 'before': true, 'after': true }
],
'no-console': 'error',
'react/prop-types': 0
},
'settings': {
'react': {
'version': 'detect'
}
}
}
17 changes: 17 additions & 0 deletions .github/workflows/health_check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Periodic Health Check

on:
workflow_dispatch:
schedule:
- cron: '0 0 * * *'

jobs:
health_check:
runs-on: ubuntu-latest
steps:
- name: Check health
uses: jtalk/url-health-check-action@v4
with:
url: https://full-stack-open-pokedex-q7ae.onrender.com/health
max-attempts: 3
retry-delay: 5s
17 changes: 17 additions & 0 deletions .github/workflows/hello.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Hello World!

on:
push:
branches:
- main

jobs:
hello:
runs-on: ubuntu-latest
steps:
- name: Say hello
run: echo "Hello World!"
- name: Print date
run: date
- name: List files
run: ls -l
71 changes: 71 additions & 0 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Deployment pipeline

on:
push:
branches:
- main
pull_request:
branches: [main]
types: [opened, synchronize]

jobs:
simple_deployment_pipeline:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install dependencies
run: npm install
- name: Check style
run: npm run eslint
- name: Run tests
run: npm test -- --watchAll=false
- name: Build
run: npm run build
- name: Install Playwright browsers
run: npx playwright install --with-deps
- name: Run E2E tests
run: npm run test:e2e
- name: Trigger deployment to Render
if: ${{ github.event_name == 'push' && !contains(join(github.event.commits.*.message, ' '), '#skip') }}
run: curl ${{ secrets.RENDER_DEPLOY_HOOK }}

tag_release:
needs: [simple_deployment_pipeline]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Bump version and push tag
if: ${{ github.event_name == 'push' && !contains(join(github.event.commits.*.message, ' '), '#skip') }}
uses: anothrNick/github-tag-action@1.75.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DEFAULT_BUMP: patch

notify_success:
needs: [simple_deployment_pipeline]
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' && !contains(join(github.event.commits.*.message, ' '), '#skip') }}
steps:
- name: Notify Discord on success
uses: sarisia/actions-status-discord@v1
with:
webhook: ${{ secrets.DISCORD_WEBHOOK }}
status: success
title: "New version deployed"
description: "Deployment to production was successful!"

notify_failure:
needs: [simple_deployment_pipeline]
runs-on: ubuntu-latest
if: ${{ failure() }}
steps:
- name: Notify Discord on failure
uses: sarisia/actions-status-discord@v1
with:
webhook: ${{ secrets.DISCORD_WEBHOOK }}
status: failure
title: "Build failed!"
description: "Commit ${{ github.sha }} by ${{ github.actor }} broke the build!"
18 changes: 5 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
# Full Stack open CI/CD
# Full Stack Open Pokedex

This repository is used for the CI/CD module of the Full stack open course
## Deployed App
https://full-stack-open-pokedex-q7ae.onrender.com

Fork the repository to complete course exercises

## Commands

Start by running `npm install` inside the project folder

`npm start` to run the webpack dev server
`npm test` to run tests
`npm run eslint` to run eslint
`npm run build` to make a production build
`npm run start-prod` to run your production build
## My CI/CD Pipeline App Repository
https://github.com/Ranjeet2020-ai/my-cicd-pipeline
23 changes: 16 additions & 7 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
const express = require("express");
const app = express();
/* eslint-env node */
const express = require('express')
const app = express()

// get the port from env variable
const PORT = process.env.PORT || 5000;
const PORT = process.env.PORT || 5000

app.use(express.static("dist"));
app.use(express.static('dist'))

app.get('/health', (req, res) => {
res.send('ok')
})

app.get('/version', (req, res) => {
res.send('1')
})

app.listen(PORT, () => {
console.log(`server started on port ${PORT}`);
});
// eslint-disable-next-line no-console
console.log(`server started on port ${PORT}`)
})
5 changes: 5 additions & 0 deletions build_step.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
echo "Installing dependencies..."
npm install
echo "Building app..."
npm run build
14 changes: 14 additions & 0 deletions e2e-tests/pokedex.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/* eslint-env node */
const { test, expect } = require('@playwright/test')

test('front page can be opened', async ({ page }) => {
await page.goto('/')
await expect(page.getByText('ivysaur')).toBeVisible()
await expect(page.getByText('Pokémon and Pokémon character names are trademarks of Nintendo.')).toBeVisible()
})

test('can navigate to ivysaur page', async ({ page }) => {
await page.goto('/')
await page.getByText('ivysaur').click()
await expect(page.getByText('chlorophyll')).toBeVisible()
})
Loading