From 24a8b52ad1951107591be225e829427879dd4613 Mon Sep 17 00:00:00 2001 From: "Arrobo, Gabriel" Date: Wed, 21 Feb 2024 11:12:59 -0800 Subject: [PATCH] Refactor GitHub Actions --- .github/workflows/delete-untagged.yml | 2 +- .github/workflows/fossa-scanning.yml | 23 ---- .github/workflows/golangci-lint.yml | 25 ---- .github/workflows/manual.yml | 39 ------ .github/workflows/markdown.yml | 19 --- .github/workflows/master.yml | 123 ++++++++++++++++++ .../{pull_request.yml => pull-request.yml} | 44 +++---- .github/workflows/py-workflow.yml | 38 ------ .github/workflows/reuse.yml | 18 --- .../workflows/run-pfcp-agent-unit-test.yml | 21 --- .github/workflows/stale.yml | 26 ++-- .github/workflows/test-integration.yml | 31 ----- 12 files changed, 152 insertions(+), 257 deletions(-) delete mode 100644 .github/workflows/fossa-scanning.yml delete mode 100644 .github/workflows/golangci-lint.yml delete mode 100644 .github/workflows/manual.yml delete mode 100644 .github/workflows/markdown.yml create mode 100644 .github/workflows/master.yml rename .github/workflows/{pull_request.yml => pull-request.yml} (77%) delete mode 100644 .github/workflows/py-workflow.yml delete mode 100644 .github/workflows/reuse.yml delete mode 100644 .github/workflows/run-pfcp-agent-unit-test.yml delete mode 100644 .github/workflows/test-integration.yml diff --git a/.github/workflows/delete-untagged.yml b/.github/workflows/delete-untagged.yml index 5427c4cd5..b2bc3b6a4 100644 --- a/.github/workflows/delete-untagged.yml +++ b/.github/workflows/delete-untagged.yml @@ -1,6 +1,6 @@ # SPDX-License-Identifier: Apache-2.0 # Copyright 2021 Intel Corporation -name: Delete untagged images +name: Untagged images on: schedule: diff --git a/.github/workflows/fossa-scanning.yml b/.github/workflows/fossa-scanning.yml deleted file mode 100644 index 6ecb6f173..000000000 --- a/.github/workflows/fossa-scanning.yml +++ /dev/null @@ -1,23 +0,0 @@ -# Copyright 2024 Intel Corporation -# SPDX-License-Identifier: Apache-2.0 - -name: Fossa check - -on: - pull_request: - branches: - - master - push: - branches: - - master - -jobs: - fossa-check: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: FOSSA scan - uses: fossa-contrib/fossa-action@v3 - with: - fossa-api-key: 0c3bbcdf20e157bbd487dae173751b28 diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml deleted file mode 100644 index f15ba69b7..000000000 --- a/.github/workflows/golangci-lint.yml +++ /dev/null @@ -1,25 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# Copyright 2020-Present Intel Corporation -# Copyright 2021 Open Networking Foundation -name: golangci-lint -on: - push: - tags: - - v* - branches: - - master - pull_request: -jobs: - golangci: - name: lint - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-go@v5 - with: - go-version-file: 'go.mod' - - name: golangci-lint - uses: golangci/golangci-lint-action@v4.0.0 - with: - version: latest - args: -v --config ./.golangci.yml diff --git a/.github/workflows/manual.yml b/.github/workflows/manual.yml deleted file mode 100644 index 032eb80eb..000000000 --- a/.github/workflows/manual.yml +++ /dev/null @@ -1,39 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# Copyright 2021 Intel Corporation - -# This is a basic workflow that is manually triggered - -name: BESS Build Base Image - -# Controls when the action will run. Workflow runs when manually triggered using -# the UI or API. -on: - schedule: - - cron: '0 0 * * SUN' - workflow_dispatch: -jobs: - build: - env: - REPO: "ghcr.io/omec-project/upf-epc/bess_build" - TAG: "latest" - BESS_DPDK_BRANCH: "dpdk-2011-focal" - DOCKER_PULL: "" - runs-on: ubuntu-20.04 - steps: - - name: docker build - run: | - git clone -b ${{ env.BESS_DPDK_BRANCH }} https://github.com/omec-project/bess.git - cd bess/env - yes n | ./rebuild_images.py focal64 - - uses: actions/checkout@v4 - - name: Build UPF with new base - run: | - make docker-build - - uses: docker/login-action@v3.0.0 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.CR_PAT }} - - name: docker push - run: | - docker push ${{ env.REPO }}:${{ env.TAG }} diff --git a/.github/workflows/markdown.yml b/.github/workflows/markdown.yml deleted file mode 100644 index a4a4bf916..000000000 --- a/.github/workflows/markdown.yml +++ /dev/null @@ -1,19 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# Copyright 2023 Intel Corporation - -name: Spellcheck -on: - - pull_request - -jobs: - check-spelling: - name: Markdown spellcheck - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Check Spelling - uses: rojopolis/spellcheck-github-actions@0.36.0 - with: - config_path: .spellcheck.yml - task_name: Markdown diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml new file mode 100644 index 000000000..c8343e279 --- /dev/null +++ b/.github/workflows/master.yml @@ -0,0 +1,123 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2023 Canonical Ltd. +# Copyright 2024 Intel Corporation + +name: Master workflow + +on: + pull_request: + branches: + - master + push: + branches: + - master + +jobs: + lint: + name: lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-go@v5 + with: + go-version-file: 'go.mod' + + - name: golangci-lint + uses: golangci/golangci-lint-action@v4.0.0 + with: + version: latest + args: -v --config ./.golangci.yml + + check-spelling: + name: Markdown spellcheck + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Check Spelling + uses: rojopolis/spellcheck-github-actions@0.36.0 + with: + config_path: .spellcheck.yml + task_name: Markdown + + route-control-tests: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.11' + + - name: Create virtual environment + run: python -m venv venv + + - name: Install dependencies + run: | + source ./venv/bin/activate + pip install -r requirements.txt + + - name: Run tests + run: | + source ./venv/bin/activate + python -m unittest ./conf/test_route_control.py + + - name: Clean up virtual environment + run: rm -rf venv + + unit-tests-pfcp: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-go@v5 + with: + go-version-file: 'go.mod' + + - name: Run unit tests for PFCP Agent + run: make test + + integration-tests-up4: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-go@v5 + with: + go-version-file: 'go.mod' + + - name: Run integration tests for PFCP Agent & UP4 + run: make test-up4-integration-docker || (docker logs pfcpiface; exit 1) + + integration-tests-bess: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-go@v5 + with: + go-version-file: 'go.mod' + + - name: Run integration tests for PFCP Agent & UP4 + run: make test-bess-integration-native + + license-check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: reuse lint + uses: fsfe/reuse-action@v1 + + fossa-check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: FOSSA scan + uses: fossa-contrib/fossa-action@v3 + with: + fossa-api-key: 0c3bbcdf20e157bbd487dae173751b28 diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull-request.yml similarity index 77% rename from .github/workflows/pull_request.yml rename to .github/workflows/pull-request.yml index 9ac96359d..a04aefac2 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull-request.yml @@ -18,38 +18,30 @@ jobs: VERSION: "PR-${{ github.event.pull_request.number }}" runs-on: ubuntu-latest steps: - # Checkout and build - uses: actions/checkout@v4 - with: - persist-credentials: false - name: Generate protobuf - run: | - make pb + run: make pb - name: Build the BESS-UPF Docker image - run: | - DOCKER_TARGETS=bess make docker-build + run: DOCKER_TARGETS=bess make docker-build - name: Build the PFCP Agent Docker image - run: | - DOCKER_TARGETS=pfcpiface make docker-build + run: DOCKER_TARGETS=pfcpiface make docker-build + + - uses: actions/setup-go@v5 + with: + go-version-file: 'go.mod' - # Format the code - name: Shell Format + # https://github.com/mvdan/sh/issues/288 run: | wget -qO shfmt https://github.com/mvdan/sh/releases/download/v3.1.1/shfmt_v3.1.1_linux_amd64 chmod +x shfmt && sudo mv shfmt /bin - # https://github.com/mvdan/sh/issues/288 shfmt -l -w $(shfmt -f . | grep -v vendor/) - - uses: actions/setup-go@v5 - with: - go-version-file: 'go.mod' - - name: Go Format - run: | - make fmt + run: make fmt - name: Python format run: | @@ -58,8 +50,7 @@ jobs: isort . - name: Show all CI changes - run: | - git --no-pager diff + run: git --no-pager diff # Verify P4 constants - name: Build P4 constants @@ -72,25 +63,21 @@ jobs: if: ${{ steps.check.outputs.PORCELAIN != '' }} uses: actions/github-script@v7 with: - script: | - core.setFailed('Please run make p4-constants and commit changes') + script: core.setFailed('Please run make p4-constants and commit changes') # Build again and commit - name: Build the BESS-UPF Docker image (after format) - run: | - DOCKER_TARGETS=bess make docker-build + run: DOCKER_TARGETS=bess make docker-build - name: Build the PFCP Agent Docker image (after format) - run: | - DOCKER_TARGETS=pfcpiface make docker-build + run: DOCKER_TARGETS=pfcpiface make docker-build # - name: Update PR with changes # uses: gr2m/create-or-update-pull-request-action@v1.x # env: # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # with: -# body: | -# Updated with changes from CI +# body: Updated with changes from CI # branch: ${{ github.event.pull_request.head.ref }} # author: "Github Actions " # commit-message: "Actions: Updated with changes from CI" @@ -106,5 +93,4 @@ jobs: - name: Push Docker image if: steps.docker-login.conclusion == 'success' - run: | - make docker-push + run: make docker-push diff --git a/.github/workflows/py-workflow.yml b/.github/workflows/py-workflow.yml deleted file mode 100644 index 1f287ab99..000000000 --- a/.github/workflows/py-workflow.yml +++ /dev/null @@ -1,38 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# Copyright 2023 Canonical Ltd. -# Copyright 2023 Intel Corporation - -name: Python Lint and Test - -on: - - push - - pull_request - -jobs: - route-control-tests: - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: '3.11' - - - name: Create virtual environment - run: python -m venv venv - - - name: Install dependencies - run: | - source ./venv/bin/activate - pip install -r requirements.txt - - - name: Run tests - run: | - source ./venv/bin/activate - python -m unittest ./conf/test_route_control.py - - - name: Clean up virtual environment - run: rm -rf venv diff --git a/.github/workflows/reuse.yml b/.github/workflows/reuse.yml deleted file mode 100644 index 91e435b62..000000000 --- a/.github/workflows/reuse.yml +++ /dev/null @@ -1,18 +0,0 @@ -# Copyright 2020-present Open Networking Foundation -# SPDX-License-Identifier: Apache-2.0 - -name: REUSE Compliance Check - -on: - push: - branches: - - master - pull_request: - -jobs: - license-check: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: reuse lint - run: make check-reuse diff --git a/.github/workflows/run-pfcp-agent-unit-test.yml b/.github/workflows/run-pfcp-agent-unit-test.yml deleted file mode 100644 index 3e6ba24d4..000000000 --- a/.github/workflows/run-pfcp-agent-unit-test.yml +++ /dev/null @@ -1,21 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# Copyright 2022-present Open Networking Foundation -name: Unit tests - -on: - push: - branches: - - master - pull_request: - -jobs: - unit-test-pfcpiface: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-go@v5 - with: - go-version-file: 'go.mod' - - name: Run unit tests for PFCP Agent - run: | - make test diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index b0dfe5853..bbe8ad59a 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -1,23 +1,23 @@ # SPDX-License-Identifier: Apache-2.0 # Copyright 2019 Intel Corporation -name: Mark stale issues and pull requests +name: Stale issues/PRs on: schedule: - - cron: "0 0 * * *" + - cron: "0 0 * * *" jobs: stale: - runs-on: ubuntu-latest - steps: - - uses: actions/stale@v9 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - stale-issue-message: 'This issue has been stale for 30 days and will be closed in 5 days. Comment to keep it open.' - stale-pr-message: 'This pull request has been stale for 30 days and will be closed in 5 days. Comment to keep it open.' - stale-issue-label: 'stale/issue' - stale-pr-label: 'stale/pr' - days-before-stale: 30 - days-before-close: 5 + - uses: actions/stale@v9 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + stale-issue-message: 'This issue has been stale for 30 days and will be closed in 5 days. Comment to keep it open.' + stale-pr-message: 'This pull request has been stale for 30 days and will be closed in 5 days. Comment to keep it open.' + stale-issue-label: 'stale/issue' + stale-pr-label: 'stale/pr' + exempt-issue-labels: 'awaiting-approval,work-in-progress' + exempt-pr-labels: 'awaiting-approval,work-in-progress' + days-before-stale: 30 + days-before-close: 5 diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml deleted file mode 100644 index 395efaa0e..000000000 --- a/.github/workflows/test-integration.yml +++ /dev/null @@ -1,31 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# Copyright 2022-present Open Networking Foundation -name: E2E integration tests - -on: - push: - branches: - - master - pull_request: - -jobs: - test-integration-up4-docker: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-go@v5 - with: - go-version-file: 'go.mod' - - name: Run integration tests for PFCP Agent & UP4 - run: | - make test-up4-integration-docker || (docker logs pfcpiface; exit 1) - test-integration-bess-native: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-go@v5 - with: - go-version-file: 'go.mod' - - name: Run integration tests for PFCP Agent & UP4 - run: | - make test-bess-integration-native