From b5f9a30a744120af65207f56d196616955250d47 Mon Sep 17 00:00:00 2001 From: Nikita Skrynnik Date: Mon, 19 Sep 2022 18:58:44 +0700 Subject: [PATCH 1/3] add reusable workflows Signed-off-by: Nikita Skrynnik --- .github/workflows/automerge.yaml | 20 +---- .github/workflows/ci.yaml | 66 +++------------ .github/workflows/pr-for-updates.yaml | 20 +---- .../update-dependent-repositories-gomod.yaml | 82 +++---------------- 4 files changed, 26 insertions(+), 162 deletions(-) diff --git a/.github/workflows/automerge.yaml b/.github/workflows/automerge.yaml index de838d104..b314acd24 100644 --- a/.github/workflows/automerge.yaml +++ b/.github/workflows/automerge.yaml @@ -8,25 +8,9 @@ on: - 'ci' jobs: automerge-on-success: - name: Automerge - runs-on: ubuntu-latest if: ${{ github.event.workflow_run.conclusion == 'success' && github.actor == 'nsmbot' }} - steps: - - name: Check out the code - uses: actions/checkout@v2 - - name: Fetch main - run: | - git remote -v - git fetch --depth=1 origin main - - name: Only allow go.mod and go.sum changes - run: | - find . -type f ! -name 'go.mod' ! -name 'go.sum' ! -name '*.yaml' ! -name '*.yml' -exec git diff --exit-code origin/main -- {} + - - name: Merge PR - uses: ridedott/merge-me-action@master - with: - GITHUB_LOGIN: nsmbot - ENABLED_FOR_MANUAL_CHANGES: true - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + uses: networkservicemesh/.github/.github/workflows/automerge.yaml@main + automerge-otherwise: name: Automerge runs-on: ubuntu-latest diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 4295276d9..30c877e12 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -7,64 +7,20 @@ on: - 'release/**' jobs: yamllint: - name: yamllint - runs-on: ubuntu-latest - steps: - - name: Check out code into the Go module directory - uses: actions/checkout@v2 - - name: Setup Python - uses: actions/setup-python@v1 - - name: Install yamllint - run: pip install --user yamllint - - name: Run yamllint - run: ~/.local/bin/yamllint -c .yamllint.yml --strict . + uses: networkservicemesh/.github/.github/workflows/yamllint.yaml@main + shellcheck: - name: shellcheck - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: shellcheck - uses: fkautz/shell-linter@v1.0.1 + uses: networkservicemesh/.github/.github/workflows/shellcheck.yaml@main + golangci-lint: - name: golangci-lint - runs-on: ubuntu-latest - steps: - - name: Check out code into the Go module directory - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - name: Setup Go - uses: actions/setup-go@v1 - with: - go-version: 1.16 - - name: golangci-lint - uses: golangci/golangci-lint-action@v3 - with: - version: v1.35 - excludeFmtErrorf: - name: exclude fmt.Errorf - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Exclude fmt.Errorf - run: | - if grep -r --include=*.go --exclude=*.pb.go fmt.Errorf . ; then - echo "Please use errors.Errorf (or errors.New or errors.Wrap or errors.Wrapf) as appropriate rather than fmt.Errorf" - exit 1 - fi + uses: networkservicemesh/.github/.github/workflows/golangci-lint.yaml@main + + exclude-fmt-errorf: + uses: networkservicemesh/.github/.github/workflows/exclude-fmt-errorf.yaml@main + checkgomod: - name: check go.mod and go.sum - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-go@v1 - with: - go-version: 1.16 - - run: go mod tidy - - name: Check for changes in go.mod or go.sum - run: | - git diff --name-only --exit-code go.mod || ( echo "Run go tidy" && false ) - git diff --name-only --exit-code go.sum || ( echo "Run go tidy" && false ) + uses: networkservicemesh/.github/.github/workflows/checkgomod.yaml@main + kind: runs-on: ubuntu-latest strategy: diff --git a/.github/workflows/pr-for-updates.yaml b/.github/workflows/pr-for-updates.yaml index ed6ef4d85..86c9ea965 100644 --- a/.github/workflows/pr-for-updates.yaml +++ b/.github/workflows/pr-for-updates.yaml @@ -6,20 +6,6 @@ on: - update/** jobs: auto-pull-request: - name: Pull Request on update/* Branch Push - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Construct PR message - run: | - PULL_REQUEST_BODY=$(git log --pretty='format:%B' -1 | sed '/^$/d;$d' | sed 's/#/# /g') - echo "$PULL_REQUEST_BODY" - echo "PULL_REQUEST_BODY<> $GITHUB_ENV - echo "$PULL_REQUEST_BODY" >> $GITHUB_ENV - echo "EOF" >> $GITHUB_ENV - - name: pull-request-action - uses: vsoch/pull-request-action@1.0.12 - env: - GITHUB_TOKEN: ${{ secrets.NSM_BOT_GITHUB_TOKEN }} - BRANCH_PREFIX: "update/" - PULL_REQUEST_BRANCH: "main" + uses: networkservicemesh/.github/.github/workflows/pr-for-updates.yaml@main + secrets: + token: ${{ secrets.NSM_BOT_GITHUB_TOKEN }} diff --git a/.github/workflows/update-dependent-repositories-gomod.yaml b/.github/workflows/update-dependent-repositories-gomod.yaml index ce92065d4..2ac72f544 100644 --- a/.github/workflows/update-dependent-repositories-gomod.yaml +++ b/.github/workflows/update-dependent-repositories-gomod.yaml @@ -11,76 +11,14 @@ on: - 'automerge' jobs: update-dependent-repositories: - continue-on-error: true - strategy: - fail-fast: false - matrix: - repository: - - integration-k8s-packet - - integration-k8s-gke - - integration-k8s-aks - - integration-k8s-aws - - integration-interdomain-k8s - name: Update ${{ matrix.repository }} - runs-on: ubuntu-latest if: ${{ github.event.workflow_run.conclusion == 'success' && github.actor == 'nsmbot' || github.event_name == 'push' }} - steps: - - name: Print environment with masked secrets - run: printenv - - name: Checkout ${{ github.repository }} - uses: actions/checkout@v2 - with: - path: ${{ github.repository }} - repository: ${{ github.repository }} - token: ${{ secrets.NSM_BOT_GITHUB_TOKEN }} - - name: Find merged PR - uses: jwalton/gh-find-current-pr@v1.0.2 - id: findPr - with: - sha: ${{ github.sha }} - github-token: ${{ github.token }} - - name: Create commit message - working-directory: ${{ github.repository }} - run: | - echo "Update go.mod and go.sum to latest version from ${{ github.repository }}@main" >> /tmp/commit-message - echo "PR link: https://github.com/${{ github.repository }}/pull/${{ steps.findPr.outputs.pr }}" >> /tmp/commit-message - echo "" >> /tmp/commit-message - LOG_MSG=$(git log --date=iso --pretty='format:Commit: %h%nAuthor: %an%nDate: %ad%nMessage:%n - %B%n' -1 | sed '/^$/d;$d') - for((i=2;i<=18;i+=2)); do n=$(printf '%*s' $((i+2))) m=$(printf '%*s' $i) LOG_MSG=$(echo "$LOG_MSG" | tr '\n' '|' | sed "s/${m}-/${n}-/2g" | tr '|' '\n'); done - echo "$LOG_MSG" >> /tmp/commit-message - echo "Commit Message:" - cat /tmp/commit-message - - uses: actions/setup-go@v1 - with: - go-version: 1.16 - - name: Get current integration-tests version - id: get-integration-tests-version - working-directory: ${{ github.repository }} - run: | - echo "::set-output name=value::$(go list -m -f '{{ .Version }}' github.com/networkservicemesh/integration-tests)" - - name: Checkout networkservicemesh/${{ matrix.repository }} - uses: actions/checkout@v2 - with: - path: networkservicemesh/${{ matrix.repository }} - repository: networkservicemesh/${{ matrix.repository }} - token: ${{ secrets.NSM_BOT_GITHUB_TOKEN }} - - name: Update networkservicemesh/${{ matrix.repository }} locally - working-directory: networkservicemesh/${{ matrix.repository }} - run: | - GOPRIVATE=github.com/networkservicemesh go get github.com/networkservicemesh/integration-tests@${{ steps.get-integration-tests-version.outputs.value }} - go mod tidy - git diff - - name: Push update to the ${{ matrix.repository }} - working-directory: networkservicemesh/${{ matrix.repository }} - run: | - echo Starting to update repositotry ${{ matrix.repository }} - git config --global user.email "nsmbot@networkservicmesh.io" - git config --global user.name "NSMBot" - git add go.mod go.sum - if ! [ -n "$(git diff --cached --exit-code)" ]; then - echo ${{ matrix.repository }} is up to date - exit 0; - fi - git commit -s -F /tmp/commit-message - git checkout -b update/${{ github.repository }} - git push -f origin update/${{ github.repository }} + uses: networkservicemesh/.github/.github/workflows/update-dependent-repositories-gomod.yaml@main + with: + dependent_repositories: | + ["integration-k8s-packet", + "integration-k8s-gke", + "integration-k8s-aks", + "integration-k8s-aws", + "integration-interdomain-k8s"] + secrets: + token: ${{ secrets.NSM_BOT_GITHUB_TOKEN }} From 6dffa6ab5d448bf1d53521b95309ce2e5c7cc7f9 Mon Sep 17 00:00:00 2001 From: Nikita Skrynnik Date: Mon, 19 Sep 2022 19:31:27 +0700 Subject: [PATCH 2/3] move yamllint config file to .ci folder Signed-off-by: Nikita Skrynnik --- .yamllint.yml => .ci/yamllint.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .yamllint.yml => .ci/yamllint.yml (100%) diff --git a/.yamllint.yml b/.ci/yamllint.yml similarity index 100% rename from .yamllint.yml rename to .ci/yamllint.yml From ebfa06719ab0e66933343a1fbd62f4dab51747aa Mon Sep 17 00:00:00 2001 From: Nikita Skrynnik Date: Tue, 8 Nov 2022 21:32:43 +0700 Subject: [PATCH 3/3] add token to automerge workflow Signed-off-by: Nikita Skrynnik --- .github/workflows/automerge.yaml | 2 ++ go.mod | 39 ++++++++++++++++++++++++++++++-- 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/.github/workflows/automerge.yaml b/.github/workflows/automerge.yaml index b314acd24..8a5453936 100644 --- a/.github/workflows/automerge.yaml +++ b/.github/workflows/automerge.yaml @@ -10,6 +10,8 @@ jobs: automerge-on-success: if: ${{ github.event.workflow_run.conclusion == 'success' && github.actor == 'nsmbot' }} uses: networkservicemesh/.github/.github/workflows/automerge.yaml@main + secrets: + token: ${{ secrets.NSM_BOT_GITHUB_TOKEN }} automerge-otherwise: name: Automerge diff --git a/go.mod b/go.mod index ca9e066e0..dbcaecbeb 100644 --- a/go.mod +++ b/go.mod @@ -1,10 +1,45 @@ module github.com/networkservicemesh/integration-k8s-kind -go 1.16 +go 1.18 require ( - github.com/googleapis/gnostic v0.5.1 // indirect github.com/networkservicemesh/integration-tests v0.0.0-20221023172725-a239c379e3bd github.com/stretchr/testify v1.7.0 +) + +require ( + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/go-logr/logr v0.2.0 // indirect + github.com/gogo/protobuf v1.3.1 // indirect + github.com/golang/protobuf v1.4.3 // indirect + github.com/google/gofuzz v1.1.0 // indirect + github.com/google/uuid v1.2.0 // indirect + github.com/googleapis/gnostic v0.5.1 // indirect + github.com/imdario/mergo v0.3.5 // indirect + github.com/json-iterator/go v1.1.10 // indirect + github.com/kelseyhightower/envconfig v1.4.0 // indirect + github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect + github.com/modern-go/reflect2 v1.0.1 // indirect + github.com/networkservicemesh/gotestmd v0.0.0-20220628095933-eabbdc09e0dc // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/sirupsen/logrus v1.8.1 // indirect + github.com/spf13/pflag v1.0.5 // indirect + golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0 // indirect + golang.org/x/net v0.0.0-20201110031124-69a78807bb2b // indirect + golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d // indirect + golang.org/x/sys v0.0.0-20211116061358-0a5406a5449c // indirect + golang.org/x/text v0.3.4 // indirect + golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e // indirect + google.golang.org/appengine v1.6.5 // indirect + google.golang.org/protobuf v1.25.0 // indirect + gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect + gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 // indirect + k8s.io/api v0.20.5 // indirect + k8s.io/apimachinery v0.20.5 // indirect + k8s.io/client-go v0.20.5 // indirect + k8s.io/klog/v2 v2.4.0 // indirect + k8s.io/utils v0.0.0-20201110183641-67b214c5f920 // indirect + sigs.k8s.io/structured-merge-diff/v4 v4.0.2 // indirect + sigs.k8s.io/yaml v1.2.0 // indirect )