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

Feature1 #231

Open
wants to merge 44 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
7745cd3
added action
RaduTuodr Sep 29, 2024
59b6b97
added action
RaduTuodr Sep 29, 2024
714d0a5
added date action
RaduTuodr Sep 29, 2024
0f93d69
added date action
RaduTuodr Sep 29, 2024
d79551d
added pipeline action
RaduTuodr Sep 29, 2024
75b85e4
eslint fixes
RaduTuodr Sep 29, 2024
20588c8
eslint fixes
RaduTuodr Sep 29, 2024
11688e8
eslint fixes
RaduTuodr Sep 29, 2024
15255c4
added build+test action
RaduTuodr Sep 29, 2024
b86b75c
added e2e testing action
RaduTuodr Sep 30, 2024
fe2722a
fixed pipeline action
RaduTuodr Sep 30, 2024
13f049d
eslint small fixes
RaduTuodr Sep 30, 2024
456da40
remove indentation rule
RaduTuodr Sep 30, 2024
331c228
remove jest testing
RaduTuodr Sep 30, 2024
a5705ab
finalised e2e action testing
RaduTuodr Sep 30, 2024
2152b01
eslint fixes
RaduTuodr Sep 30, 2024
810340e
updated port
RaduTuodr Sep 30, 2024
ce63381
small fix
RaduTuodr Sep 30, 2024
c09427a
small fix
RaduTuodr Sep 30, 2024
f942f65
CD done with Fly.io
RaduTuodr Oct 1, 2024
a7504ce
updated CD yml files
RaduTuodr Oct 3, 2024
12afc8c
fixed e2e test action
RaduTuodr Oct 3, 2024
1c23ff3
removed running script
RaduTuodr Oct 4, 2024
c6a1725
added http check
RaduTuodr Oct 4, 2024
b5b1fb3
removed comment
RaduTuodr Oct 4, 2024
84b7cee
deploy only when PR to main
RaduTuodr Oct 4, 2024
94530a3
added tagbump action
RaduTuodr Oct 5, 2024
1ad640d
removed hello.yml + default_bump fix
RaduTuodr Oct 5, 2024
aa2bb87
fixed param def_bump
RaduTuodr Oct 5, 2024
defab3d
removed if statement in tag action
RaduTuodr Oct 5, 2024
cfd0af5
added checkout to tag action
RaduTuodr Oct 5, 2024
064e960
finalised tag bump
RaduTuodr Oct 5, 2024
ed7789a
added test action
RaduTuodr Oct 5, 2024
96b89f0
check commit m for skip
RaduTuodr Oct 5, 2024
36619af
fixed test action
RaduTuodr Oct 5, 2024
c6fa1a9
added name to test #skip
RaduTuodr Oct 5, 2024
036007b
added tag_notify action
RaduTuodr Oct 6, 2024
058d595
check node.js v in tag_notify
RaduTuodr Oct 6, 2024
45f514e
patch fly-deploy
RaduTuodr Oct 6, 2024
d3460bb
patch fly-deploy
RaduTuodr Oct 6, 2024
283d27f
patch fly-deploy
RaduTuodr Oct 6, 2024
17d0f95
patch fly-deploy
RaduTuodr Oct 6, 2024
17a478f
added notiforiginal format
RaduTuodr Oct 6, 2024
17b7deb
patch fly-deploy
RaduTuodr Oct 6, 2024
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
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules/
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
PORT = 5000
FLY_AUTH_TOKEN = 'fo1_GtFOaY4YcQwO4BOvFOhFIcY0YjGCuigSb9XooyvC6qk'
70 changes: 34 additions & 36 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,49 +1,47 @@
module.exports = {
"env": {
"browser": true,
"es6": true,
"jest/globals": true
'env': {
'node': true,
'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': 'off',
'linebreak-style': [
'error',
'unix'
],
"quotes": [
"error",
"single"
'quotes': [
'error',
'single'
],
"semi": [
"error",
"never"
'semi': [
'error',
'never'
],
"eqeqeq": "error",
"no-trailing-spaces": "error",
"object-curly-spacing": [
"error", "always"
'eqeqeq': 'error',
'no-trailing-spaces': 'error',
'object-curly-spacing': [
'error', 'always'
],
"arrow-spacing": [
"error", { "before": true, "after": true }
'arrow-spacing': [
'error', { 'before': true, 'after': true }
],
"no-console": "error",
"react/prop-types": 0
'no-console': 'error',
'react/prop-types': 0
}
}
62 changes: 62 additions & 0 deletions .github/workflows/fly-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Fly Deploy
on:
push:
branches:
- main
pull_request:
branches: [main]
types: [opened, synchronize]

jobs:
deploy:
name: Deploy app
runs-on: ubuntu-latest
concurrency: deploy-group
steps:
- uses: actions/checkout@v4
- uses: superfly/flyctl-actions/setup-flyctl@master
- name: Install dependencies
run: npm install
- name: Build app
run: npm run build
- run: flyctl deploy --remote-only
if: ${{ github.event_name == 'push' }}
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}

tag_release:
needs: [deploy]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Bump version and push tag
uses: anothrNick/github-tag-action@f278d49d30cdd8775cc3e7dd00b5ee11686ee297
if: ${{ github.event_name == 'push' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DEFAULT_BUMP: patch

tag_notify:
name: Notify change
needs: [tag_release]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: New release notification
uses: rjstone/discord-webhook-notify@v1
if: success()
with:
severity: info
details: New tag released!
webhookUrl: ${{ secrets.DISCORD_WEBHOOK }}

# - name: New release notification
# if: success()
# run: |
# curl -H "Content-Type: application/json" -d '{"content": "Hello! New tag has been released!"}' ${{ secrets.DISCORD_WEBHOOK }}

- name: Build failed notification
if: failure()
run: |
curl -H "Content-Type: application/json" -d '{"content": "**ERROR:** Build failed! Please check the logs."}' ${{ secrets.DISCORD_WEBHOOK }}
24 changes: 24 additions & 0 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Deployment Pipeline


on:
push:
branches:
- main

jobs:
simple_deployment_pipeline:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20.12.1'
- name: Install dependencies
run: npm install
- name: Check Style
run: npm run eslint
- name: Build
run: npm run build --verbose
- name: e2e tests
run: npm run test:e2e
19 changes: 19 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Testing stuff

on:
push:
branches:
- main

jobs:
test_commit_skip:
runs-on: ubuntu-20.04
steps:
- name: Useless name
uses: actions/checkout@v4

- name: Check if skip tag-bump
if: ${{ !contains(toJson(github.event.commits.*.message), '#skip') }}
env:
COMMIT_MESSAGES: ${{ toJson(github.event.commits.*.message) }}
run: echo "$COMMIT_MESSAGES"
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
dist/
node_modules/
node_modules/
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
45 changes: 45 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# syntax = docker/dockerfile:1

# Adjust NODE_VERSION as desired
ARG NODE_VERSION=20.12.1
FROM node:${NODE_VERSION}-slim as base

LABEL fly_launch_runtime="Node.js"

# Node.js app lives here
WORKDIR /app

# Set production environment
ENV NODE_ENV="production"


# Throw-away build stage to reduce size of final image
FROM base as build

# Install packages needed to build node modules
RUN apt-get update -qq && \
apt-get install --no-install-recommends -y build-essential node-gyp pkg-config python-is-python3

# Install node modules
COPY package-lock.json package.json ./
RUN npm ci --include=dev

# Copy application code
COPY . .

# Build application
RUN npm run build

# Remove development dependencies
RUN npm prune --omit=dev


# Final stage for app image
FROM base

# Copy built application
COPY --from=build /app /app

# Start the server by default, this can be overwritten at runtime
EXPOSE 3000
CMD [ "npm", "run", "start" ]
21 changes: 13 additions & 8 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
const express = require("express");
const app = express();
import express from 'express'
const app = express()

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

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

app.listen(PORT, () => {
console.log(`server started on port ${PORT}`);
});
app.get('/version', (req, res) => {
res.send('1')
})

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

app.listen(PORT)
20 changes: 20 additions & 0 deletions e2e/Pokemon.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { test, describe, expect } from '@playwright/test'

describe('Pokedex', () => {
test('front page can be opened', async ({ page }) => {
await page.goto('http://localhost:8080')

await expect(page.getByText('ivysaur')).toBeVisible()
await expect(page.getByText('Pokémon and Pokémon character names are trademarks of Nintendo.'))
.toBeVisible()
})

test('test page navigation', async ({ page }) => {

await page.goto('http://localhost:8080')

await page.getByText(/^ivysaur$/).click()

await expect(page.getByText(/^chlorophyll$/)).toBeVisible()
})
})
35 changes: 35 additions & 0 deletions fly.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# fly.toml app configuration file generated for full-stack-open-pokedex-little-star-5652 on 2024-10-01T13:48:15+03:00
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#

app = 'full-stack-open-pokedex-little-star-5652'
primary_region = 'syd'

[build]

[env]
PORT = "3000" # add this where PORT matches the internal_port below

[processes]
app = "node app.js" # add this

[http_service]
internal_port = 3000
force_https = true
auto_stop_machines = 'stop'
auto_start_machines = true
min_machines_running = 0
processes = ['app']

[[http_service.checks]]
grace_period = "10s"
interval = "30s"
method = "GET"
timeout = "5s"
path = "/health"

[[vm]]
memory = '1gb'
cpu_kind = 'shared'
cpus = 1
Loading