Skip to content

Commit b4605d5

Browse files
authored
ci: common ci flow PL-87 (#1252)
* ci: common CI workflow * ci: remove unnecessary console log * ci: rename buildTest command
1 parent 9ef9414 commit b4605d5

7 files changed

Lines changed: 82 additions & 35 deletions

File tree

.github/workflows/ci.yml

Lines changed: 52 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,54 @@
11
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
22
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
33

4-
name: Continuous Integration
4+
name: CI
55

66
on:
77
push:
88
branches: [ main ]
99
pull_request:
1010
branches: [ main ]
11+
# Allows you to run this workflow manually from the Actions tab
12+
workflow_dispatch:
1113

1214
jobs:
13-
build:
15+
common:
16+
uses: City-of-Helsinki/.github/.github/workflows/ci-node.yml@main
17+
secrets: inherit
18+
with:
19+
node-version: 22.x
20+
extra-commands: |
21+
echo "PORT=2048" >> $GITHUB_ENV
22+
echo "SSR_FETCH_TIMEOUT=2500" >> $GITHUB_ENV
23+
echo "ACCESSIBILITY_SENTENCE_API=https://www.hel.fi/palvelukarttaws/rest/v4" >> $GITHUB_ENV
24+
echo "SERVICEMAP_API=https://api.hel.fi/servicemap/" >> $GITHUB_ENV
25+
echo "SERVICEMAP_API_VERSION=v2" >> $GITHUB_ENV
26+
echo "EVENTS_API=https://api.hel.fi/linkedevents/v1" >> $GITHUB_ENV
27+
echo "RESERVATIONS_API=https://varaamo.hel.fi" >> $GITHUB_ENV
28+
echo "PRODUCTION_PREFIX=SM" >> $GITHUB_ENV
29+
echo "DIGITRANSIT_API=https://digitransit-proxy.api.hel.fi/routing/v1/routers/hsl/index/graphql" >> $GITHUB_ENV
30+
echo "FEEDBACK_URL=https://api.hel.fi/servicemap/open311/" >> $GITHUB_ENV
31+
echo "HEARING_MAP_API=https://kuulokuvat.fi/api/v1/servicemap-url" >> $GITHUB_ENV
32+
echo "MODE=production" >> $GITHUB_ENV
33+
echo "CITIES=helsinki,espoo,vantaa,kauniainen,kirkkonummi" >> $GITHUB_ENV
34+
echo "ORGANIZATIONS=[{ \"id\": \"83e74666-0836-4c1d-948a-4b34a8b90301\", \"name\": { \"fi\": \"Helsingin kaupunki\", \"sv\": \"Helsingfors stad\", \"en\": \"City of Helsinki\" } },{ \"id\": \"520a4492-cb78-498b-9c82-86504de88dce\", \"name\": { \"fi\": \"Espoon kaupunki\", \"sv\": \"Esbo stad\", \"en\": \"City of Espoo\" } },{ \"id\": \"6d78f89c-9fd7-41d9-84e0-4b78c0fa25ce\", \"name\": { \"fi\": \"Vantaan kaupunki\", \"sv\": \"Vanda stad\", \"en\": \"City of Vantaa\" } },{ \"id\": \"6f0458d4-42a3-434a-b9be-20c19fcfa5c3\", \"name\": { \"fi\": \"Kauniaisten kaupunki\", \"sv\": \"Grankulla stad\", \"en\": \"Town of Kauniainen\" } },{ \"id\": \"015fd5cd-b280-4d24-a5b4-0ba6ecb4c8a4\", \"name\": { \"fi\": \"Kirkkonummi\", \"sv\": \"Kyrkslätt\", \"en\": \"Kirkkonummi\" } },{ \"id\": \"0c8e4f99-3d52-47b9-84df-395716bd8b11\", \"name\": { \"fi\": \"Länsi-Uudenmaan hyvinvointialue\", \"sv\": \"Västra Nylands välfärdsområde\", \"en\": \"Western Uusimaa Wellbeing Services County\" } },{ \"id\": \"5de91045-92ab-484b-9f96-7010ff7fb35e\", \"name\": { \"fi\": \"Vantaan ja Keravan hyvinvointialue\", \"sv\": \"Vanda och Kervo välfärdsområde\", \"en\": \"Wellbeing services county of Vantaa and Kerava\" } }]" >> $GITHUB_ENV
35+
echo "SERVICE_MAP_URL=https://helsinki-maptiles.dev.hel.ninja/styles/hel-osm-bright-{language}/{z}/{x}/{y}{suffix}.png" >> $GITHUB_ENV
36+
echo "ACCESSIBLE_MAP_URL=https://helsinki-maptiles.dev.hel.ninja/styles/turku-osm-high-contrast-pattern-{language}/{z}/{x}/{y}{suffix}.png" >> $GITHUB_ENV
37+
echo "ORTOGRAPHIC_MAP_URL=https://kartta.hsy.fi/geoserver/gwc/service/wmts?layer=taustakartat_ja_aluejaot:Ortoilmakuva_2019&tilematrixset=ETRS-GK25&Service=WMTS&Request=GetTile&Version=1.0.0&TileMatrix=ETRS-GK25:{z}&TileCol={x}&TileRow={y}&Format=image/png" >> $GITHUB_ENV
38+
echo "ORTOGRAPHIC_WMS_URL=https://kartta.hsy.fi/geoserver/wms" >> $GITHUB_ENV
39+
echo "ORTOGRAPHIC_WMS_LAYER=taustakartat_ja_aluejaot:Ortoilmakuva_2019" >> $GITHUB_ENV
40+
echo "GUIDE_MAP_URL=https://kartta.hel.fi/ws/geoserver/avoindata/gwc/service/wmts?layer=avoindata:Karttasarja_PKS&tilematrixset=ETRS-GK25&Service=WMTS&Request=GetTile&Version=1.0.0&TileMatrix=ETRS-GK25:{z}&TileCol={x}&TileRow={y}&Format=image/png" >> $GITHUB_ENV
41+
echo "PLAIN_MAP_URL=https://mml-tiles.hel.ninja/avoin/wmts/1.0.0/selkokartta/default/ETRS-TM35FIN/{z}/{y}/{x}.png" >> $GITHUB_ENV
42+
echo "READ_FEEDBACK_URLS_HELSINKI=https://palautteet.hel.fi/fi/hae-palautteita#/app/search?r=12&text=,https://palautteet.hel.fi/sv/hae-palautteita#/app/search?r=12&text=,https://palautteet.hel.fi/en/hae-palautteita#/app/search?r=12&text=" >> $GITHUB_ENV
43+
echo "ADDITIONAL_FEEDBACK_URLS_ESPOO=https://easiointi.espoo.fi/eFeedback/fi,https://easiointi.espoo.fi/eFeedback/sv,https://easiointi.espoo.fi/eFeedback/en" >> $GITHUB_ENV
44+
echo "ADDITIONAL_FEEDBACK_URLS_KAUNIAINEN=https://www.kauniainen.fi/kaupunki-ja-paatoksenteko/osallistu-ja-vaikuta/,https://www.kauniainen.fi/sv/staden-och-beslutsfattande/delta-och-paverka/,https://www.kauniainen.fi/kaupunki-ja-paatoksenteko/osallistu-ja-vaikuta/" >> $GITHUB_ENV
45+
echo "ADDITIONAL_FEEDBACK_URLS_KIRKKONUMMI=https://kirkkonummi.fi/anna-palautetta-ja-vaikuta/,https://kyrkslatt.fi/ge-respons-och-paverka/,https://kirkkonummi.fi/anna-palautetta-ja-vaikuta/" >> $GITHUB_ENV
46+
echo "ADDITIONAL_FEEDBACK_URLS_VANTAA=https://www.vantaa.fi/fi/palaute,https://www.vantaa.fi/sv/feedback,https://www.vantaa.fi/en/feedback" >> $GITHUB_ENV
47+
echo "SLOW_FETCH_MESSAGE_TIMEOUT=3000" >> $GITHUB_ENV
48+
echo "HELSINKI_MAPTILES_ENABLED=true" >> $GITHUB_ENV
1449
50+
e2e:
51+
needs: common
1552
runs-on: ubuntu-latest
1653

1754
env:
@@ -44,21 +81,17 @@ jobs:
4481
SLOW_FETCH_MESSAGE_TIMEOUT: 3000
4582
HELSINKI_MAPTILES_ENABLED: true
4683

47-
strategy:
48-
matrix:
49-
node-version: [22.x]
50-
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
51-
5284
steps:
53-
- uses: actions/checkout@v4
54-
with:
55-
fetch-depth: 0
56-
- name: Use Node.js ${{ matrix.node-version }}
57-
uses: actions/setup-node@v4
58-
with:
59-
node-version: ${{ matrix.node-version }}
60-
- run: yarn install --frozen-lockfile
61-
- run: yarn testBuild
62-
- run: yarn test
63-
- run: yarn test:e2e:install
64-
- run: yarn test:e2e
85+
- uses: actions/checkout@v4
86+
- name: Use Node.js 22.x
87+
uses: actions/setup-node@v4
88+
with:
89+
node-version: 22.x
90+
- name: Install dependencies
91+
run: yarn install --frozen-lockfile
92+
- name: Build application
93+
run: yarn build
94+
- name: Install Playwright browsers
95+
run: yarn test:e2e:install
96+
- name: Run E2E tests
97+
run: yarn test:e2e

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Start dev server and runs the app in the development mode.<br>
2121

2222
Builds the app for production to the `dist` folder.<br>
2323

24-
### `yarn testBuild`
24+
### `yarn build:test`
2525

2626
Builds the app in development mode to the `dist` folder.<br>
2727

config/default.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function getVersion() {
1515
if (typeof window !== 'undefined' && typeof window.nodeEnvSettings !== 'undefined') {
1616
version = window.nodeEnvSettings.appVersion;
1717
}
18-
console.log('Palvelukartta version:', `${version.tag} / ${version.commit}`);
18+
// On local development, version is not set, but works ok with undefined.
1919
return version;
2020
}
2121

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,12 @@
6363
"scripts": {
6464
"start": "node dist",
6565
"build": "NODE_ENV=production BABEL_ENV=production webpack --mode production ",
66-
"testBuild": "NODE_ENV=development BABEL_ENV=development webpack --mode development",
66+
"build:test": "NODE_ENV=development BABEL_ENV=development webpack --mode development",
6767
"test": "jest test",
68+
"test:coverage": "jest test --coverage",
6869
"test:e2e:install": "playwright install",
6970
"test:e2e": "playwright test",
71+
"lint": ":",
7072
"eject": "react-scripts eject",
7173
"dev": "NODE_ENV=development BABEL_ENV=development webpack --watch --progress & nodemon dist",
7274
"production": "NODE_ENV=production BABEL_ENV=production webpack --progress --mode production && node dist"
@@ -101,7 +103,6 @@
101103
"eslint-plugin-jsx-a11y": "^6.4.1",
102104
"eslint-plugin-react": "^7.32.2",
103105
"eslint-plugin-react-hooks": "^4.5.0",
104-
"git-revision-webpack-plugin": "5.0.0",
105106
"identity-obj-proxy": "^3.0.0",
106107
"jest": "^29.5.0",
107108
"jest-canvas-mock": "^2.5.1",

sonar-project.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ sonar.projectVersion=1.0
99
sonar.sourceEncoding=UTF-8
1010

1111
# Exclude translation files from duplication analysis
12-
sonar.exclusions=**/i18n/*,**/__tests__/**,e2e/**/*,playwright.config.js
12+
sonar.exclusions=**/i18n/*,**/__tests__/**,e2e/**/*,playwright.config.js,webpack.config.js

webpack.config.js

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,31 @@ const css = {
6767
],
6868
};
6969

70+
const getGitTag = () => {
71+
try {
72+
return cp.execSync('git describe --abbrev=0 --tags', { cwd: '.' })
73+
.toString()
74+
.replace(/\r?\n|\r/g, '');
75+
} catch (error) {
76+
// Fallback when no tags exist
77+
return 'no-tag';
78+
}
79+
};
80+
81+
const getGitCommit = () => {
82+
try {
83+
return cp.execSync('git rev-parse --short HEAD', { cwd: '.' })
84+
.toString()
85+
.trim();
86+
} catch (error) {
87+
// Fallback when git is not available
88+
return 'unknown';
89+
}
90+
};
91+
7092
const gitVersionInfoPlugin = new webpack.DefinePlugin({
71-
GIT_TAG: JSON.stringify(cp.execSync('git describe --abbrev=0 --tags', { cwd: '.' })
72-
.toString()
73-
.replace(/\r?\n|\r/g, '')),
74-
GIT_COMMIT: JSON.stringify(cp.execSync('git rev-parse --short HEAD', { cwd: '.' })
75-
.toString()
76-
.trim()),
93+
GIT_TAG: JSON.stringify(getGitTag()),
94+
GIT_COMMIT: JSON.stringify(getGitCommit()),
7795
});
7896

7997
const plugins = [gitVersionInfoPlugin];

yarn.lock

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7143,11 +7143,6 @@ get-symbol-description@^1.1.0:
71437143
es-errors "^1.3.0"
71447144
get-intrinsic "^1.2.6"
71457145

7146-
git-revision-webpack-plugin@5.0.0:
7147-
version "5.0.0"
7148-
resolved "https://registry.yarnpkg.com/git-revision-webpack-plugin/-/git-revision-webpack-plugin-5.0.0.tgz#0683a6a110ece618499880431cd89e1eb597b536"
7149-
integrity sha512-RptQN/4UKcEPkCBmRy8kLPo5i8MnF8+XfAgFYN9gbwmKLTLx4YHsQw726H+C5+sIGDixDkmGL3IxPA2gKo+u4w==
7150-
71517146
glob-parent@^5.1.2, glob-parent@~5.1.2:
71527147
version "5.1.2"
71537148
resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4"

0 commit comments

Comments
 (0)