diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5379f236..3292ce6a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,7 +11,7 @@ name: Build Frontend on: push: branches: - - main + - dev/new-frontend-ci-with-cypress pull_request: branches: - main @@ -20,17 +20,101 @@ on: 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 + 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 + run: | + + # Download Tomcat + wget -q https://ftp.unicamp.br/pub/apache/tomcat/tomcat-10/v10.1.19/bin/apache-tomcat-10.1.19.tar.gz + + # Extract Tomcat + 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: Setup Node uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0 @@ -40,21 +124,35 @@ jobs: cache-dependency-path: '**/package-lock.json' - name: 📦 Install constrained dependencies + working-directory: sw360-frontend shell: bash run: | npm ci - name: 🔄 Check for outdated dependencies + working-directory: sw360-frontend shell: bash run: | npm outdated || echo "::warning title=Outdated dependencies::Some dependencies are outdated and need to be updated" - name: Run linting + working-directory: sw360-frontend shell: bash run: | npm run lint - - name: Run build - shell: bash + - name: Start frontend + working-directory: sw360-frontend run: | npm run build + npm 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 \ No newline at end of file diff --git a/cypress.env.json b/cypress.env.json index e367bca6..aff7274f 100644 --- a/cypress.env.json +++ b/cypress.env.json @@ -4,8 +4,8 @@ "couchdb_ip": "localhost", "couchdb_port": "5984", "couchdb_dbname": "sw360db", - "couchdb_username": "admin", - "couchdb_password": "password", + "couchdb_username": "sw360", + "couchdb_password": "sw360fossie", "couchdb_users_dbname": "sw360users", "couchdb_oauth_clients_dbname": "sw360oauthclients" } \ No newline at end of file