Commit ba6d5f7d authored by Vlasák Jan's avatar Vlasák Jan
Browse files

inital import (not sync with cesko digital)

parent 15881aad
File added
# editorconfig.org
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.md]
trim_trailing_whitespace = false
\ No newline at end of file
# Drupal git normalization
# @see https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html
# @see https://www.drupal.org/node/1542048
# Normally these settings would be done with macro attributes for improved
# readability and easier maintenance. However macros can only be defined at the
# repository root directory. Drupal avoids making any assumptions about where it
# is installed.
# Define text file attributes.
# - Treat them as text.
# - Ensure no CRLF line-endings, neither on checkout nor on checkin.
# - Detect whitespace errors.
# - Exposed by default in `git diff --color` on the CLI.
# - Validate with `git diff --check`.
# - Deny applying with `git apply --whitespace=error-all`.
# - Fix automatically with `git apply --whitespace=fix`.
*.config text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
*.css text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
*.dist text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
*.engine text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2 diff=php
*.html text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2 diff=html
*.inc text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2 diff=php
*.install text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2 diff=php
*.js text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
*.json text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
*.lock text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
*.map text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
*.md text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
*.module text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2 diff=php
*.php text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2 diff=php
*.po text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
*.profile text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2 diff=php
*.script text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
*.sh text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2 diff=php
*.sql text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
*.svg text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
*.theme text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2 diff=php
*.twig text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
*.txt text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
*.xml text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
*.yml text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
# Define binary file attributes.
# - Do not treat them as text.
# - Include binary diff in patches instead of "binary files differ."
*.eot -text diff
*.exe -text diff
*.gif -text diff
*.gz -text diff
*.ico -text diff
*.jpeg -text diff
*.jpg -text diff
*.otf -text diff
*.phar -text diff
*.png -text diff
*.svgz -text diff
*.ttf -text diff
*.woff -text diff
*.woff2 -text diff
name: "Deploy"
on:
workflow_dispatch:
schedule:
- cron: '0 * * * *'
jobs:
build:
name: Build Gatsby
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v2.1.2
with:
node-version: 14
- name: Install dependencies
run: |
sudo apt-get update && sudo apt-get install -y ca-certificates wget apt-transport-https gnupg apt-utils curl git g++ \
&& curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - \
&& echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list \
&& sudo apt update && sudo apt install yarn -y
- name: Build Gatsby
run: |
export GATSBY_APPINSIGHTS_KEY=${{ secrets.GATSBY_APPINSIGHTS_KEY }} \
&& yarn install \
&& yarn build \
working-directory: gatsby
- name: Checkout gh-pages
run: |
git clone https://git:${{ secrets.GITHUB_TOKEN }}@github.com/cesko-digital/covid.gov.cz.git --branch gh-pages gh-pages &&
rm -rf gh-pages/* gh-pages/.github
- name: Move new build
run: |
mv gatsby/public/* gh-pages \
&& cp .gitattributes gh-pages
- name: Set identity
run: |
git config --global user.email "bot@cesko.digital" && git config --global user.name "Bot Cesko.Digital"
- name: Commit && move on
working-directory: gh-pages
run: |
git add -A && git commit -m "Build" --allow-empty && git push --force
- name: Send notification to Slack
uses: rtCamp/action-slack-notify@master
env:
SLACK_COLOR: '#3278BD'
SLACK_ICON: https://covid.gov.cz/favicon.svg
SLACK_USERNAME: "Nový build"
SLACK_MESSAGE: "Máme nový build :tada:, deploy na produkci probíhá 20 minut po celé hodině."
SLACK_FOOTER: ""
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
MSG_MINIMAL: true
name: Gatsby
on:
push:
pull_request:
paths:
- "gatsby/*"
defaults:
run:
working-directory: ./gatsby
jobs:
validate:
name: Validate Gatsby Code Base
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v1
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-
- name: Install dependencies
run: yarn install
- name: Run prettier check
run: yarn format
- name: Run eslint check
run: yarn lint:eslint
- name: Run stylelint check
run: yarn lint:styles
- name: Build frontend
run: yarn build
- name: Run typescript check
run: yarn lint:tsc
- name: Run tests
run: yarn test
name: Drupal
on:
push:
branches:
- master
paths-ignore:
- 'gatsby/**'
- 'docker/**'
jobs:
deploy:
name: Deploy to Staging
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Install stage SSH key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_KEY_STAGE }}
name: id_rsa
known_hosts: ${{ secrets.KNOWN_HOSTS_STAGE }}
- name: Validate composer.json and composer.lock
run: cd drupal && composer validate
- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v2
with:
path: drupal/vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Install dependencies
if: steps.composer-cache.outputs.cache-hit != 'true'
run: cd drupal && composer install --no-progress --no-suggest
- name: Deploy to stage
run: cd drupal && vendor/bin/dep deploy staging
......@@ -4,6 +4,7 @@
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
......@@ -12,6 +13,9 @@
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Mono auto generated files
mono_crash.*
# Build results
[Dd]ebug/
[Dd]ebugPublic/
......@@ -19,10 +23,14 @@
[Rr]eleases/
x64/
x86/
[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
[Ll]ogs/
# Visual Studio 2015/2017 cache/options directory
.vs/
......@@ -36,9 +44,10 @@ Generated\ Files/
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUNIT
# NUnit
*.VisualState.xml
TestResult.xml
nunit-*.xml
# Build Results of an ATL Project
[Dd]ebugPS/
......@@ -52,7 +61,9 @@ BenchmarkDotNet.Artifacts/
project.lock.json
project.fragment.lock.json
artifacts/
**/Properties/launchSettings.json
# ASP.NET Scaffolding
ScaffoldingReadMe.txt
# StyleCop
StyleCopReport.xml
......@@ -60,7 +71,7 @@ StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_i.h
*_h.h
*.ilk
*.meta
*.obj
......@@ -77,6 +88,7 @@ StyleCopReport.xml
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.vspscc
*.vssscc
......@@ -119,9 +131,6 @@ _ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# JustCode is a .NET coding add-in
.JustCode
# TeamCity is a build add-in
_TeamCity*
......@@ -132,6 +141,11 @@ _TeamCity*
.axoCover/*
!.axoCover/settings.json
# Coverlet is a free, cross platform Code Coverage Tool
coverage*.json
coverage*.xml
coverage*.info
# Visual Studio code coverage results
*.coverage
*.coveragexml
......@@ -179,6 +193,8 @@ PublishScripts/
# NuGet Packages
*.nupkg
# NuGet Symbol Packages
*.snupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
......@@ -203,12 +219,14 @@ BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
*.appxbundle
*.appxupload
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/
!?*.[Cc]ache/
# Others
ClientBin/
......@@ -221,7 +239,7 @@ ClientBin/
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
......@@ -252,6 +270,9 @@ ServiceFabricBackup/
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
*- [Bb]ackup.rdl
*- [Bb]ackup ([0-9]).rdl
*- [Bb]ackup ([0-9][0-9]).rdl
# Microsoft Fakes
FakesAssemblies/
......@@ -287,12 +308,8 @@ paket-files/
# FAKE - F# Make
.fake/
# JetBrains Rider
.idea/
*.sln.iml
# CodeRush
.cr/
# CodeRush personal settings
.cr/personal
# Python Tools for Visual Studio (PTVS)
__pycache__/
......@@ -305,6 +322,8 @@ __pycache__/
# Tabs Studio
*.tss
.idea
# Telerik's JustMock configuration file
*.jmconfig
......@@ -317,7 +336,7 @@ __pycache__/
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
......@@ -326,5 +345,20 @@ ASALocalRun/
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# Local History for Visual Studio
.localhistory/
# BeatPulse healthcheck temp database
healthchecksdb
# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
.ionide/
# Fody - auto-generated XML schema
FodyWeavers.xsd
# How to contribute
Ideas for improvement, bug reporting and pull requests are always welcome.
## Useful Links
- Trello: https://trello.com/b/XOOBy51q
- Figma: https://www.figma.com/file/9avjIglqc1VVc84zHIoLha/CovidPortal
## Languages
In English:
- Code
- Comments
- Commit text
- README and other docs
In Czech:
- Issues and Pull Requests
## Issues
Please try to spend some time on a good title and description of the issue.
## Pull requests
If it is not a fork branch, please use the following format for your branch: `{gatsby,drupal}/{feature,bugfix,content}/slug`.
All pull requests should undergo code review. The code review can be performed by any volunteer who has been active in the project for a long time.
A Pull Request has to pass validation by Github Actions (Triggered Automatically)
## Gatsby
### Code Style
A lot of things are taken care of by ESLint and Prettier.
#### Files organization
- _kebab-case_ for all files and folders, except React components
- _PascalCase_ for React components
- extension `.tsx` for all files containing JSX code
- folder `components` is reserved for components of all kinds
- folder `pages` is for static GatsbyJS pages (file `about.tsx` will be as a page `/about`)
- folder `layout` is for dynamic pages
- component organization with its styles:
```
src
components
index.tsx // all components are exported from here
Component // if the component has only index.tsx, the folder has to be transformed into Component.tsx
index.tsx
styles.scss
SubComponent // if the sub-component has only index.tsx, the folder has to be transformed into SubComponent.tsx
index.tsx
styles.scss
// TODO: Add Tests
```
#### Styles
We use CSS Modules approach in SCSS format and extend [Czech Government Styleguide](https://designsystem.gov.cz) which are located in `gatsby/assets/ds/scss`
### Drupal
TODO: Add Drupal
# Introduction
TODO: Give a short introduction of your project. Let this section explain the objectives or the motivation behind this project.
# Getting Started
TODO: Guide users through getting your code up and running on their own system. In this section you can talk about:
1. Installation process
2. Software dependencies
3. Latest releases
4. API references
# Build and Test
TODO: Describe and show how to build your code and run the tests.
# Contribute
TODO: Explain how other users and developers can contribute to make your code better.
If you want to learn more about creating good readme files then refer the following [guidelines](https://docs.microsoft.com/en-us/azure/devops/repos/git/create-a-readme?view=azure-devops). You can also seek inspiration from the below readme files:
- [ASP.NET Core](https://github.com/aspnet/Home)
- [Visual Studio Code](https://github.com/Microsoft/vscode)
- [Chakra Core](https://github.com/Microsoft/ChakraCore)
\ No newline at end of file
# COVID Portal 🦠 🖥 🇨🇿
## Links
- 🖥 **production version** - [https://covid.gov.cz/](https://covid.gov.cz/)
- 🛠 "staging" version - [https://covidportal.dev/](https://covidportal.dev/) (hosted on Vercel)
- [Trello](https://trello.com/b/XOOBy51q/covidgovcz)
## Contribute
- join 🇨🇿 **cesko.digital** through - [https://join.cesko.digital/](https://join.cesko.digital/)
1. after receiving slack link, join us in the respective channel:
`#p-informacni-web-ceska`
`#p-informacni-web-frontend`
`#p-informacni-web-drupal`
2. introduce yourself + just fork this project or just ask for GitHub privileges in our Slack
3. choose your starter task from our [Trello](https://trello.com/b/XOOBy51q/covidgovcz)
4. create a branch and PR for the task
*we usually tend to use a descriptive PR title e.g.:* `gatsby/feat: task title` *or* `drupal/fix: task title`, *i guess you get the point*
6. after PR creation:
- we will receive a notification in our slack channel to do the review
- your branch will be deployed to a feature branch on Vercel (comment by Vercel bot)
- check your changes in the prod build on Vercel
7. after the review and approval ✅, we will merge the PR and it will be eventually deployed to production
## Getting started
### Frontend - Gatsby
If you only want to run frontend part of this app, you **dont have to install Docker** and the backend part. It works standalone as well - see the frontend for more details
- 🚀 [see how to get up and running with the frontend](/gatsby/README.md#gatsby) ➡️
### Backend - Drupal
We're using docker containers from `docker` folder:
- `cd docker`
Copy and modify env file as needed
- `cp .env.example .env`
Start containers
- `docker-compose up -d`
Install dependencies
- `docker-compose exec drupal composer install`
Install Drupal with existing config, database connection is already injected in settings.php file
- `docker-compose exec drupal drush si --existing-config -y`
Access site on `http://localhost:1577` if you didn't change
`COVID_PORT_NGINX` variable in your `env` file
\ No newline at end of file
# Tato pipeline tvoří image pro Covid Drupal
# Jestli budeme pipeline automaticky spoustet
trigger: none
# vytvoříme si jméno buildu
name: $(BuildDefinitionName)_$(SourceBranchName)_$(Date:yyyyMMdd)$(Rev:.r)
jobs:
- job: LinuxJob
displayName: 'Linux job for build'
# Na jakem poolu buildujeme
pool:
name: 'NakitLocalPool'
# Promenne pro build
variables:
- name: 'HelmChartVerMajor'
value: '1'
- name: 'HelmChartVerMinor'
value: '1'
- name: 'HelmChartVerPatch'
value: $[counter(variables['minor'], 0)]
# tady referencujeme sdílené proměnné
- group: 'Nakit-pipelines-shared'
- name: 'system.debug'
value: true
# build context má adresář source, protože právě tam děláme cheout z gitu (viz. steps.checkout)
- name: 'buildContext'
value: '$(Agent.BuildDirectory)/src'
# helm directory má adresář helm, protože právě tam děláme cheout z gitu (viz. steps.checkout)
- name: 'helmDirectory'
value: '$(Agent.BuildDirectory)/helm'
# nazev connection kterou pouzijeme na spojeni do docker registry
- name: 'containerRegistryServiceConnection'
value: "DockerRegistryPopocNativ"
# docker repository pro podepsanou image
- name: "imageRepositoryNotSigned"
value: "k8s/covid/notsigned"
# pomocný flag, jestli se má buildovat image
- name: 'buildImage'
value: true
# pomocný flag, jestli se má modifikovat Helm,vytvořit release ticket a vytvořit pull request na modifikaci helmu
- name: 'createHelmChange'
value: true
steps:
# checkout self (zdrojáky covidu)
- checkout: self
clean: true
path: 'src'
# checkout Helm git repository a persistCredentials je kvůli tomu, že v pipeline provádíme git push, takže potřebujeme oauth token kvůli právům na git repo
- checkout: git://PortalObcana/helm@refs/heads/master
clean: true
persistCredentials: true
path: 'helm'
# Proměnnou tagImage (pro docker tag) si musíme splitnout z BuildNumber. Nelze jí sestavit ve variables deklaraci z důvodu viditelnosti tokenů typu datum a rev
- task: PowerShell@2
name: setVariableTag
displayName: 'Set variable tag'
inputs: