forked from eclipse-sw360/sw360-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
155 lines (133 loc) · 5.06 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# Copyright (c) Helio Chissini de Castro, 2023. Part of the SW360 Frontend Project.
#
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
# License-Filename: LICENSE
name: Build Frontend
on:
push:
branches:
- dev/new-frontend-ci-with-cypress
pull_request:
branches:
- main
workflow_dispatch:
permissions:
contents: read
env:
COUCHDB_USER: sw360
COUCHDB_PASSWORD: sw360fossie
TOMCAT_DIR: /opt/apache-tomcat-10.1.19
THRIFT_VERSION: 0.20.0
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Extract Organization Name
run: |
ORG_NAME=$(echo $GITHUB_REPOSITORY | cut -d'/' -f1)
echo "ORG_NAME=$ORG_NAME" >> $GITHUB_ENV
- name: Harden Runner
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
with:
egress-policy: audit
- name: Set up JDK 21
uses: actions/setup-java@8df1039502a15bceb9433410b1a100fbe190c53b # v4.5.0
with:
java-version: "21"
distribution: "temurin"
check-latest: true
- name: Checkout sw360-backend
uses: actions/checkout@v4
with:
repository: ${{ env.ORG_NAME }}/sw360
token: ${{ secrets.GITHUB_TOKEN }}
path: sw360-backend
- name: Setup CouchDB
working-directory: sw360-backend
run: scripts/startCouchdbForTests.sh
- name: Update properties with DB credentials
shell: bash
run: |
sudo mkdir -p /etc/sw360
sudo mkdir /etc/sw360/authorization
sudo mkdir /etc/sw360/rest
sudo cp sw360-backend/rest/resource-server/src/main/resources/application.yml /etc/sw360/rest
sudo cp sw360-backend/scripts/docker-config/etc_sw360/authorization/application.yml /etc/sw360/authorization
sudo sed -i 's|http://couchdb:5984|http://localhost:5984|g' /etc/sw360/authorization/application.yml
sudo cp sw360-backend/build-configuration/resources/couchdb.properties /etc/sw360/couchdb.properties
sudo sed -i 's/^couchdb.user\s*=/& '${COUCHDB_USER}'/' /etc/sw360/couchdb.properties
sudo sed -i 's/^couchdb.password\s*=/& '${COUCHDB_PASSWORD}'/' /etc/sw360/couchdb.properties
- name: Cache Thrift
id: cache-thrift
uses: actions/cache@v4
with:
path: |
/usr/local/bin/thrift
/usr/share/thrift/${{ env.THRIFT_VERSION }}
key: ${{ runner.os }}-thrift-${{ env.THRIFT_VERSION }}
restore-keys: |
${{ runner.os }}-thrift-${{ env.THRIFT_VERSION }}
- name: Install Thrift
working-directory: sw360-backend
if: steps.cache-thrift.outputs.cache-hit != 'true'
run: |
sudo apt-get update -qq
sudo DEBIAN_FRONTEND=noninteractive apt-get install -yq build-essential libevent-dev libtool flex bison pkg-config libssl-dev git cmake
chmod +x scripts/install-thrift.sh
DESTDIR=${{ github.workspace }}/dist/thrift-${{ env.THRIFT_VERSION }} scripts/install-thrift.sh
- name: Download and Install Tomcat
shell: bash
run: |
wget -q https://ftp.unicamp.br/pub/apache/tomcat/tomcat-10/v10.1.19/bin/apache-tomcat-10.1.19.tar.gz
tar -xvzf apache-tomcat-10.1.19.tar.gz -C /opt/ > /dev/null 2>&1
- name: Build and start sw360-backend
working-directory: sw360-backend
shell: bash
run: |
export PATH="${{ github.workspace }}/dist/thrift-${{ env.THRIFT_VERSION }}/usr/local/bin:$PATH"
mvn clean install --no-transfer-progress -P deploy -Dbase.deploy.dir=${TOMCAT_DIR} -DskipTests
bash /opt/apache-tomcat-10.1.19/bin/startup.sh
env:
SW360_CORS_ALLOWED_ORIGIN: '*'
- name: Checkout source code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
path: sw360-frontend
- name: pnpm-setup
uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0
with:
version: 8
- name: Setup Node
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version: '22'
cache: 'pnpm'
- name: 📦 Install dependencies
working-directory: sw360-frontend
shell: bash
run: |
pnpm i
- name: Run linting
working-directory: sw360-frontend
shell: bash
run: |
pnpm lint
- name: Build and start sw360-frontend
working-directory: sw360-frontend
shell: bash
run: |
pnpm build
pnpm i nohup -g
nohup npm start &
env:
NEXT_PUBLIC_SW360_API_URL: http://localhost:8080
NEXTAUTH_SECRET: secret
NEXTAUTH_URL: http://localhost:3000
- name: Execute e2e testing
working-directory: sw360-frontend
run: |
npx cypress run