diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml new file mode 100644 index 0000000..32a8dfa --- /dev/null +++ b/.github/workflows/docker-build.yml @@ -0,0 +1,35 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2025 Canonical Ltd. +name: Docker Build + +on: + workflow_call: + inputs: + branch_name: + description: "Name of the branch to checkout" + required: false + type: string + default: ${{ github.ref }} + build_directory: + description: "Directory where to run the build command from" + required: false + type: string + default: '.' + make_target: + description: "Makefile target to build" + required: false + type: string + default: "docker-build" + +jobs: + docker-build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ inputs.branch_name }} + + - name: Build Docker image + run: | + cd ${{ inputs.build_directory }} + make ${{ inputs.make_target }} diff --git a/.github/workflows/docs-publish.yml b/.github/workflows/docs-publish.yml new file mode 100644 index 0000000..e1aedf0 --- /dev/null +++ b/.github/workflows/docs-publish.yml @@ -0,0 +1,49 @@ +# Copyright 2025 The Linux Foundation +# SPDX-FileCopyrightText: 2025 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 +name: Publish Documents +# Calling workflow should include "secrets: inherit" + +on: + workflow_call: + inputs: + remote_host: + description: "Address for host to sync charts to" + required: true + type: string + remote_path: + description: "Path on remote_host where charts should be stored" + required: true + type: string + +jobs: + publish: + runs-on: ubuntu-latest + env: + BUILD_OUTPUT_PATH: _build/multiversion/ + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: 3.11 + + - name: Build docs + run: make multiversion + + - name: List built files + run: ls $BUILD_OUTPUT_PATH* + + - name: rsync deployments + uses: burnett01/rsync-deployments@7.0.1 + with: + switches: -rvzh --delete-after --exclude=.git + path: ${{ env.BUILD_OUTPUT_PATH }} + remote_path: ${{ inputs.remote_path }} + remote_host: ${{ inputs.remote_host }} + remote_user: ${{ secrets.JENKINS_USERNAME }} + remote_key: ${{ secrets.JENKINS_SSHKEY }} + remote_key_pass: ${{ secrets.JENKINS_PASSPHRASE }} diff --git a/.github/workflows/go-build-test.yml b/.github/workflows/go-build-test.yml new file mode 100644 index 0000000..85046f8 --- /dev/null +++ b/.github/workflows/go-build-test.yml @@ -0,0 +1,33 @@ +# Copyright 2025 The Linux Foundation +# SPDX-FileCopyrightText: 2025 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 +name: Build and Test Go + +on: + workflow_call: + inputs: + go-mod-path: + required: false + type: string + default: "go.mod" + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version-file: ${{ inputs.go-mod-path }} + - name: build + run: make build + + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version-file: 'go.mod' + - name: Unit tests + run: make unit-test || make test diff --git a/.github/workflows/go-get-modules.yml b/.github/workflows/go-get-modules.yml new file mode 100644 index 0000000..dbb9648 --- /dev/null +++ b/.github/workflows/go-get-modules.yml @@ -0,0 +1,28 @@ +# Copyright 2025 The Linux Foundation +# SPDX-FileCopyrightText: 2025 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 +name: Get All Go Modules + +on: + workflow_call: + inputs: + go-dir: + description: "Location of Go modules to enumerate" + required: false + default: "." + outputs: + modules: + description: "Go modules in the current repo" + value: $ {{ jobs.get-modules.outputs.modules }} + +jobs: + get-modules: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: create release using REST API + run: | + echo "modules=$(find ${{ inputs.go-dir }} -name go.mod | jq -R | jq -sc)" >> $GITHUB_OUTPUT diff --git a/.github/workflows/go-lint.yml b/.github/workflows/go-lint.yml new file mode 100644 index 0000000..bc8bf07 --- /dev/null +++ b/.github/workflows/go-lint.yml @@ -0,0 +1,30 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2025 Canonical Ltd. +name: Lint Go Code + +on: + workflow_call: + inputs: + build_directory: + description: "Directory where to run the lint command from" + required: false + type: string + default: '.' + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-go@v5 + with: + go-version-file: 'go.mod' + cache: true + + - name: Run golangci-lint + uses: golangci/golangci-lint-action@v7.0.0 + with: + version: latest + args: -v --config ./.golangci.yml + working-directory: ${{ inputs.build_directory }} diff --git a/.github/workflows/go-version-check.yml b/.github/workflows/go-version-check.yml new file mode 100644 index 0000000..fa82cb4 --- /dev/null +++ b/.github/workflows/go-version-check.yml @@ -0,0 +1,50 @@ +# SPDX-FileCopyrightText: 2025 The Linux Foundation +# SPDX-License-Identifier: Apache-2.0 +name: Golang Version Check +# Calling workflow should include "secrets: inherit" + +on: + workflow_call: + outputs: + dev_version: + description: "The version for the release" + value: ${{ jobs.version-check.outputs.dev_version }} + target_version: + description: "The version for the release" + value: ${{ jobs.version-check.outputs.target_version }} + +jobs: + version-check: + if: (github.repository_owner == 'onosproject') + runs-on: ubuntu-latest + outputs: + dev_version: ${{ steps.dev-version-check-step.outputs.dev_version }} + target_version: ${{ steps.get-target-version-step.outputs.target_version }} + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: check dev version + id: dev-version-check-step + run: | + if [[ $(cat VERSION | tr -d '\n' | tail -c 4) =~ "-dev" ]]; then + echo "dev_version=true" >> $GITHUB_OUTPUT + else + echo "dev_version=false" >> $GITHUB_OUTPUT + fi + + - name: get target version + id: get-target-version-step + run: | + echo "target_version=$(cat VERSION)" >> $GITHUB_OUTPUT + + - name: check version + id: version-check-step + run: | + # check if version format is matched to SemVer + VER_REGEX='^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$' + if [[ ! $(cat VERSION | tr -d '\n' | sed s/-dev//) =~ $VER_REGEX ]]; then + exit 1 + fi + exit 0 diff --git a/.github/workflows/release-helm-charts.yml b/.github/workflows/release-helm-charts.yml index 60a9804..45d0869 100644 --- a/.github/workflows/release-helm-charts.yml +++ b/.github/workflows/release-helm-charts.yml @@ -5,26 +5,24 @@ # Copyright 2025 The Linux Foundation name: Publish image and tag/release code +# Calling workflow should include "secrets: inherit" # yamllint disable-line rule:truthy on: workflow_call: inputs: - CHARTS_REPO_URL: - description: "Repo URL to push charts to" + charts_repo_url: + description: "URL for the helm repository to push to" required: false type: string - UMBRELLA_CHART: - description: "The repository's umbrella chart, if applicable" - required: false - type: string - RSYNC_REMOTE_HOST: - description: "The remote host to sync charts to" - required: false + default: https://charts.aetherproject.org + remote_host: + description: "Address for host to sync charts to" + required: true type: string - RSYNC_REMOTE_PATH: - description: "The path on the remote host to sync charts to" - required: false + remote_path: + description: "Path on remote_host where charts should be stored" + required: true type: string jobs: @@ -81,18 +79,7 @@ jobs: version: ${{ steps.version-change.outputs.version }} version-check: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Setup yq - uses: vegardit/gha-setup-yq@v1 - - name: Check all changed charts have unique versions - id: version-change - run: | - export COMPARISON_BRANCH=${{ github.event.before }} - ${{ github.action_path }}/version_check.sh check_unique + uses: onosproject/.github/.github/workflows/version-check.yml@main tag-versions: runs-on: ubuntu-latest @@ -138,7 +125,6 @@ jobs: - name: Publish all changed charts # yamllint disable rule:line-length run: | - export COMPARISON_BRANCH=${{ github.event.before }} target_charts=${{ steps.get-charts.outputs.charts }} rm -rf staging && mkdir -p staging/${{ github.repository }} while IFS= read -r tc @@ -148,8 +134,8 @@ jobs: helm package $tc --destination staging/${{ github.repository }}/$tc done <<< $target_charts cd staging - curl -o current-index.yaml ${{ inputs.CHARTS_REPO_URL }}/index.yaml - helm repo index ${{ github.repository }} --url ${{ inputs.CHARTS_REPO_URL }}/${{ github.repository }} --merge current-index.yaml + curl -o current-index.yaml ${{ inputs.charts_repo_url }}/index.yaml + helm repo index ${{ github.repository }} --url ${{ inputs.charts_repo_url }}/${{ github.repository }} --merge current-index.yaml rm -rf current-index.yaml mv ${{ github.repository }}/index.yaml . cd .. @@ -160,8 +146,8 @@ jobs: with: switches: -rvzh path: staging/ - remote_path: ${{ inputs.RSYNC_REMOTE_PATH }} - remote_host: ${{ inputs.RSYNC_REMOTE_HOST }} + remote_path: ${{ inputs.remote_path }} + remote_host: ${{ inputs.remote_host }} remote_user: ${{ secrets.JENKINS_USERNAME }} remote_key: ${{ secrets.JENKINS_SSHKEY }} remote_key_pass: ${{ secrets.JENKINS_PASSPHRASE }} diff --git a/.github/workflows/release-image.yml b/.github/workflows/release-image.yml new file mode 100644 index 0000000..61eafcc --- /dev/null +++ b/.github/workflows/release-image.yml @@ -0,0 +1,49 @@ +# Copyright 2025 Canonical Ltd. +# SPDX-FileCopyrightText: 2025 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 +name: Release Image + +on: + workflow_call: + inputs: + docker_tag: + required: false + type: string + default: "latest" + type: string + docker_registry: + description: "Docker Registry URL" + default: "docker.io" + type: string + docker_repository: + description: "Docker Repository" + default: "onosproject/" + type: string + +jobs: + release-image: + runs-on: ubuntu-latest + env: + DOCKER_TAG: ${{ inputs.docker_tag }} + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-go@v5 + with: + go-version-file: 'go.mod' + cache: true + + - name: Login to Docker Registry + uses: docker/login-action@v3.4.0 + with: + registry: ${{ inputs.docker_registry }} + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + + - name: Build and Push to Docker Registry + env: + DOCKER_REGISTRY: ${{ inputs.docker_registry }}/ + DOCKER_REPOSITORY: ${{ inputs.docker_repository }} + run: | + make docker-build + make docker-push diff --git a/.github/workflows/tag-github.yml b/.github/workflows/tag-github.yml index 88fcbd1..bc72af0 100644 --- a/.github/workflows/tag-github.yml +++ b/.github/workflows/tag-github.yml @@ -16,6 +16,7 @@ on: jobs: tag-github: + if: github.repository_owner == 'onosproject' runs-on: ubuntu-latest outputs: changed: ${{ steps.version-change.outputs.changed }} @@ -50,7 +51,7 @@ jobs: - name: Create Github release if: steps.version-change.outputs.changed == 'true' - uses: onos-project/.github/.github/actions/create-github-release-action@main + uses: onosproject/.github/.github/actions/create-github-release-action@main with: version: ${{ steps.version-change.outputs.version }} env: diff --git a/.github/workflows/version-check.yml b/.github/workflows/version-check.yml new file mode 100644 index 0000000..e7f1555 --- /dev/null +++ b/.github/workflows/version-check.yml @@ -0,0 +1,22 @@ +# SPDX-FileCopyrightText: 2025 The Linux Foundation +# SPDX-License-Identifier: Apache-2.0 +name: Version Check +# Calling workflow should include "secrets: inherit" + +on: + workflow_call: + +jobs: + version-check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Setup yq + uses: vegardit/gha-setup-yq@v1 + - name: Check all changed charts have unique versions + id: version-change + run: | + export COMPARISON_BRANCH=${{ github.event.before }} + ${{ github.action_path }}/version_check.sh check_unique