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

tag_release #202

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
.env
81 changes: 44 additions & 37 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,49 +1,56 @@
module.exports = {
"env": {
"browser": true,
"es6": true,
"jest/globals": true
env: {
browser: true,
es6: true,
'jest/globals': true,
node: true,
'cypress/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', 'cypress'
],
"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'
}
}
}
}
20 changes: 20 additions & 0 deletions .github/workflows/fly-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
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
- run: flyctl deploy --remote-only
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
25 changes: 25 additions & 0 deletions .github/workflows/hello.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Hello World!

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

jobs:
hello_world_job:
runs-on: ubuntu-20.04
steps:
- name: Say hello
run: |
echo "Hello World!"

- name: Now it is
run: |
date

- name: Directory content
run: |
ls -l
60 changes: 60 additions & 0 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Deployment pipeline

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

jobs:

simple_deployment_pipeline:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install dependencies
run: npm install

- name: Lint
run: npm run eslint

- name: Test
run: npm run test

- name: Build
run: npm run build

- name: e2e tests
uses: cypress-io/github-action@v5
with:
command: npm run test:e2e
start: npm run start-prod
wait-on: http://localhost:5000

if: ${{ github.event_name == 'push' && !contains(github.event.head_commit.message, '#skip') }}

- name: Notify Discord on Failure
if: failure()
run: |
curl -H "Content-Type: application/json" \
-X POST \
-d "{\"content\": \"CI pipeline failed! Commit: ${{ github.sha }} by ${{ github.actor }}. Message: ${{ github.event.head_commit.message }}\"}" \
${{ secrets.DISCORD_WEBHOOK_URL }}

tag_release:
needs: [simple_deployment_pipeline]
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Bump version and push tag
uses: anothrNick/github-tag-action@1.70.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
DEFAULT_BUMP: patch
if: ${{ github.event_name == 'push' && !contains(github.event.head_commit.message, '#skip') }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
dist/
node_modules/
node_modules/
.env
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.15.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 --link package-lock.json package.json ./
RUN npm ci --include=dev

# Copy application code
COPY --link . .

# 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" ]
17 changes: 11 additions & 6 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
const express = require("express");
const app = express();
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('/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}`)
})
9 changes: 9 additions & 0 deletions cypress.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const { defineConfig } = require('cypress')

module.exports = defineConfig({
e2e: {
baseUrl: 'http://localhost:5000',
supportFile: false,
specPattern: 'cypress/*.cy.{js,jsx,ts,tsx}',
},
})
12 changes: 12 additions & 0 deletions cypress/Pokedex.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
describe('Pokedex', function() {
it('front page can be opened', function() {
cy.visit('http://localhost:5000')
cy.contains('ivysaur')
cy.contains('Pokémon and Pokémon character names are trademarks of Nintendo.')
})
it('Should visit a specific pokemon page', function() {
cy.visit('http://localhost:5000')
cy.contains('ivysaur').click()
cy.contains('chlorophyll')
})
})
21 changes: 21 additions & 0 deletions exercise1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
### Linting
Checkstyle: A development tool to help programmers write Java code that adheres to a coding standard. It automates the process of checking Java code to spare humans of this boring (but important) task.

### Testing
JUnit: The most widely used testing framework for Java. It provides annotations to identify test methods and assertions to test expected results.

### Building
1.
Maven: A build automation tool used primarily for Java projects. It addresses two aspects of building software: first, it describes how software is built, and second, it describes its dependencies.
2.
Gradle: A flexible build automation system that is designed to build almost anything. It is known for its performance and scalability, and it can be used for building, testing, and deploying software.

### Alternatives
GitLab, Bamboo, Azure DevOps Pipelines

### Needed information
Main infornation is size of a team, budge and project requirements

### Comparison
For a team of 6 people, a cloud-based CI/CD environment is better. It is easier to use and scale and also it has lower maintenance burden.
On the other side self-hosted setups there are risks of hardware failures which can be an issue if the setup sees heavy use.
26 changes: 26 additions & 0 deletions fly.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# fly.toml app configuration file generated for full-stack-open-pokedex-holy-fire-1989 on 2024-08-23T17:25:33+03:00
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#

app = 'full-stack-open-pokedex-holy-fire-1989'
primary_region = 'ams'

[build]

[env]
PORT = '3000'

[processes]
app = 'node app.js'

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

[[vm]]
size = 'shared-cpu-1x'
Loading