From c64ee305b1d36de9a66020d3a8977d9055676452 Mon Sep 17 00:00:00 2001 From: Georgi Lazarov Date: Thu, 16 Nov 2023 11:33:42 +0200 Subject: [PATCH] feat: add title check workflow (#442) Signed-off-by: georgi-l95 --- .github/workflows/browser-tests.yaml | 49 ------- .github/workflows/flow-pr-title-check.yaml | 45 +++++++ .../workflows/flow-pull-request-checks.yaml | 108 ++++++++++++++++ .github/workflows/smoke-tests.yaml | 51 -------- .github/workflows/update-config-files.yaml | 120 ------------------ 5 files changed, 153 insertions(+), 220 deletions(-) delete mode 100644 .github/workflows/browser-tests.yaml create mode 100644 .github/workflows/flow-pr-title-check.yaml create mode 100644 .github/workflows/flow-pull-request-checks.yaml delete mode 100644 .github/workflows/smoke-tests.yaml delete mode 100644 .github/workflows/update-config-files.yaml diff --git a/.github/workflows/browser-tests.yaml b/.github/workflows/browser-tests.yaml deleted file mode 100644 index 4d7d7a71..00000000 --- a/.github/workflows/browser-tests.yaml +++ /dev/null @@ -1,49 +0,0 @@ -name: Browser Tests - -on: - push: - branches: [main, develop] - pull_request: - workflow_dispatch: - -concurrency: - group: pr-checks-${{ github.workflow }}-${{ github.head_ref || github.run_id }} - cancel-in-progress: true - -jobs: - tests: - name: Browser Tests - - runs-on: ubuntu-latest - - strategy: - fail-fast: false - matrix: - node-version: [18.x] - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.node-version }} - cache: npm - - - name: Install dependencies - run: npm ci - - - name: Start the local node - run: npm run start -- -d - - - name: Prepare and run the tests - run: | - cd test/cypress - npm ci - npm run build - npm run start - npm run test - - - name: Stop the local node - run: npm run stop diff --git a/.github/workflows/flow-pr-title-check.yaml b/.github/workflows/flow-pr-title-check.yaml new file mode 100644 index 00000000..1d9764ea --- /dev/null +++ b/.github/workflows/flow-pr-title-check.yaml @@ -0,0 +1,45 @@ +## +# Copyright (C) 2023 Hedera Hashgraph, LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +## + +name: "PR Check" +on: + workflow_dispatch: + pull_request: + types: + - opened + - reopened + - edited + - synchronize + +defaults: + run: + shell: bash + +concurrency: + group: pr-checks-${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + title-check: + name: Title Check + runs-on: ubuntu-latest + permissions: + statuses: write + steps: + - name: Check PR Title + uses: aslafy-z/conventional-pr-title-action@v3 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/flow-pull-request-checks.yaml b/.github/workflows/flow-pull-request-checks.yaml new file mode 100644 index 00000000..029185e9 --- /dev/null +++ b/.github/workflows/flow-pull-request-checks.yaml @@ -0,0 +1,108 @@ +## +# Copyright (C) 2023 Hedera Hashgraph, LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +## + +name: "PR Checks" +on: + workflow_dispatch: + pull_request: + types: + - opened + - reopened + - synchronize + +defaults: + run: + shell: bash + +concurrency: + group: pr-checks-${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + smoke-tests: + name: Smoke Tests + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + node-version: [18.x] + network: [mainnet, testnet, local, previewnet] + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: npm + + - name: Install dependencies + run: | + npm ci + cd test/smoke + npm ci + + - name: Start the local node with ${{ matrix.network }} images + run: npm run start -- --network ${{ matrix.network }} -d + + - name: Run smoke test + uses: nick-fields/retry@v2 + with: + max_attempts: 3 + timeout_minutes: 3 + command: npm run test:smoke + + - name: Stop the local node + run: npm run stop + + browser-tests: + name: Browser Tests + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + node-version: [18.x] + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: npm + + - name: Install dependencies + run: npm ci + + - name: Start local node + run: npm run start -- -d + + - name: Prepare and run the tests + run: | + cd test/cypress + npm ci + npm run build + npm run start + npm run test + + - name: Stop the local node + run: npm run stop \ No newline at end of file diff --git a/.github/workflows/smoke-tests.yaml b/.github/workflows/smoke-tests.yaml deleted file mode 100644 index 018540c8..00000000 --- a/.github/workflows/smoke-tests.yaml +++ /dev/null @@ -1,51 +0,0 @@ -name: Smoke Tests -on: - push: - branches: [main, develop] - pull_request: - workflow_dispatch: - -concurrency: - group: pr-checks-${{ github.workflow }}-${{ github.head_ref || github.run_id }} - cancel-in-progress: true - -jobs: - tests: - runs-on: ubuntu-latest - - strategy: - fail-fast: false - matrix: - node-version: [18.x] - network: [mainnet, testnet, local, previewnet] - - name: ${{ matrix.network }} - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.node-version }} - cache: npm - - - name: Install dependencies - run: | - npm ci - cd test/smoke - npm ci - - - name: Start the local node with ${{ matrix.network }} images - run: npm run start -- --network ${{ matrix.network }} -d - - - name: Run smoke test - uses: nick-fields/retry@v2 - with: - max_attempts: 3 - timeout_minutes: 3 - command: npm run test:smoke - - - name: Stop the local node - run: npm run stop diff --git a/.github/workflows/update-config-files.yaml b/.github/workflows/update-config-files.yaml deleted file mode 100644 index 4eca4b10..00000000 --- a/.github/workflows/update-config-files.yaml +++ /dev/null @@ -1,120 +0,0 @@ -name: Update Config Files -on: - workflow_dispatch: - schedule: - - cron: "0 1 * * *" - -defaults: - run: - shell: bash - -permissions: - pull-requests: write - contents: write - -env: - REMOTE_RAW_URL_BASE: https://raw.githubusercontent.com - REMOTE_REPO_OWNER: hashgraph - REMOTE_REPO_NAME: hedera-services - REMOTE_CONFIG_PATH: develop/hedera-node/configuration - REMOTE_CONFIG_PROFILE: previewnet - REPO_CONFIG_PATH: compose-network/network-node/data/config - PR_REVIEWERS: "beeradb,Neeharika-Sompalli,nathanklick,tannerjfco,steven-sheehy" - PR_ASSIGNEES: "swirlds-automation" - -jobs: - hedera-node-config: - name: Hedera Node Configuration - runs-on: ubuntu-20.04 - steps: - - name: Checkout Code - uses: actions/checkout@v2 - - - name: Initialize Job Parameters - id: params - run: | - EPOCH="$(date -u +%s)" - echo "::set-output name=config-url::${REMOTE_RAW_URL_BASE}/${REMOTE_REPO_OWNER}/${REMOTE_REPO_NAME}/${REMOTE_CONFIG_PATH}/${REMOTE_CONFIG_PROFILE}" - echo "::set-output name=staging-folder::$(mktemp -dt job-staging.XXXXXXX)" - echo "::set-output name=update-time::$(date -u -d @${EPOCH})" - - - name: Download Configuration Files - run: | - FILES=("bootstrap.properties" "application.properties" "api-permission.properties") - STAGING_PATH="${{ steps.params.outputs.staging-folder }}" - - for f in "${FILES[@]}"; do - echo "::group::Retrieving File: ${f}" - curl -L -o "${STAGING_PATH}/${f}" "${{ steps.params.outputs.config-url }}/${f}" - - if [[ ! -f "${STAGING_PATH}/${f}" ]]; then - echo "::error file=${f}::File Not Found" - fi - - FILE_LEN="$(stat -L --format='%s' "${STAGING_PATH}/${f}")" - if [[ "${FILE_LEN}" -le 0 ]]; then - echo "::error file=${f},line=1,col=1,endColumn=1::Zero length file found, but file must have content." - exit 1 - fi - echo "::endgroup::" - done - - - name: Check Files for Changes - id: changes - run: | - FILES=("bootstrap.properties" "application.properties" "api-permission.properties") - FILE_HASHES="$(mktemp --tmpdir -t "file-hashes.XXXXXXXX")" - STAGING_PATH="${{ steps.params.outputs.staging-folder }}" - REPO_PATH="${{ github.workspace }}/${REPO_CONFIG_PATH}" - - CHANGES_FOUND="false" - - for f in "${FILES[@]}"; do - echo "::group::Comparing File: ${f}" - - if [[ ! -f "${REPO_PATH}/${f}" && -f "${STAGING_PATH}/${f}" ]]; then - echo "::warning file=${f}::Repository File Missing, Restoring from Staging Copy" - cp -f "${STAGING_PATH}/${f}" "${REPO_PATH}/${f}" - CHANGES_FOUND="true" - continue - fi - - if ! diff "${STAGING_PATH}/${f}" "${REPO_PATH}/${f}" >/dev/null 2>&1; then - echo "::notice file=${f}::Update Required, Applying Changes" - cp -f "${STAGING_PATH}/${f}" "${REPO_PATH}/${f}" - CHANGES_FOUND="true" - else - echo "::notice file=${f}::No Update Needed, Skipping File" - fi - - HASH="$(sha256sum "${STAGING_PATH}/${f}" | awk '{ print $1 }')" - echo "${HASH}" >> "${FILE_HASHES}" - done - - FINAL_HASH_PREFIX="$(sha256sum "${FILE_HASHES}" | awk '{ print $1 }' | cut -c1-8)" - - echo "::set-output name=found::${CHANGES_FOUND}" - echo "::set-output name=branch-name::update-config-${FINAL_HASH_PREFIX}" - - - name: Create Pull Request - uses: peter-evans/create-pull-request@v4 - if: ${{ steps.changes.outputs.found == 'true' }} - with: - signoff: true - delete-branch: true - commit-message: "[Automated Update] Hedera Configuration Files" - title: "[Automated Update] Hedera Configuration Files" - body: | - ### Description - - Automated Update of the Hedera Node Configuration Files from the official `${{ env.REMOTE_REPO_OWNER }}/${{ env.REMOTE_REPO_NAME }}` repository. - - ### Update Details - - **Detection Date/Time:** `${{ steps.params.outputs.update-time }}` - **Detection Branch:** `${{ steps.changes.outputs.branch-name }}` - - token: ${{ secrets.GITHUB_TOKEN }} - branch: ${{ steps.changes.outputs.branch-name }} - assignees: ${{ env.PR_ASSIGNEES }} - reviewers: ${{ env.PR_REVIEWERS }}