From 0a7664b406f5cb927fceed18690f797202022312 Mon Sep 17 00:00:00 2001 From: schmidtw Date: Sat, 18 Jun 2022 17:52:36 -0700 Subject: [PATCH] Update the CI to use the common workflows. --- .github/workflows/ci.yml | 22 +++++++ .github/workflows/push.yml | 107 ---------------------------------- .github/workflows/release.yml | 34 ----------- .github/workflows/tag.yml | 28 --------- .github/workflows/updater.yml | 15 +++++ .sonar-project.properties | 34 ----------- README.md | 9 +-- 7 files changed, 42 insertions(+), 207 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .github/workflows/push.yml delete mode 100644 .github/workflows/release.yml delete mode 100644 .github/workflows/tag.yml create mode 100644 .github/workflows/updater.yml delete mode 100644 .sonar-project.properties diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..4e4a624 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,22 @@ +# SPDX-FileCopyrightText: 2022 Comcast Cable Communications Management, LLC +# SPDX-License-Identifier: Apache-2.0 +--- +name: CI + +on: + push: + branches: + - main + paths-ignore: + - README.md + - CONTRIBUTING.md + - MAINTAINERS.md + - LICENSE + - NOTICE + pull_request: + workflow_dispatch: + +jobs: + ci: + uses: xmidt-org/.github/.github/workflows/go-ci.yml@go-ci-v1 + secrets: inherit diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml deleted file mode 100644 index f86a2dd..0000000 --- a/.github/workflows/push.yml +++ /dev/null @@ -1,107 +0,0 @@ -name: CI - -on: - create: - pull_request: - push: - branches: - - main - -jobs: - test: - name: Unit Tests - runs-on: [ ubuntu-latest ] - steps: - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v2 - - # Setup Go - - name: Setup Go - uses: actions/setup-go@v2 - with: - go-version: '1.18.x' # The Go version to download (if necessary) and use. - - # Run build of the application - - name: Run build - run: go build ./... - - # Run gofmt on the code - - name: Run gofmt - run: gofmt -d - - # Run testing on the code - - name: Run testing - run: | - go test -v -race -coverprofile=coverage.txt ./... - go test -race -json ./... > report.json - curl -s https://codecov.io/bash | bash - echo "codecov done" - - # upload report as artifact - - name: Archive unit tests report - uses: actions/upload-artifact@v2 - with: - name: report - path: report.json - - # upload coverage as artifact - - name: Archive code coverage results - uses: actions/upload-artifact@v2 - with: - name: coverage - path: coverage.txt - - lint: - strategy: - matrix: - go-version: [ 1.18.x ] - os: [ ubuntu-latest ] - name: Lint - runs-on: ${{ matrix.os }} - steps: - - uses: actions/checkout@v2 - - name: golangci-lint - uses: golangci/golangci-lint-action@v2 - with: - # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. - version: v1.45 - # Optional: working directory, useful for monorepos - # working-directory: somedir - - # Optional: golangci-lint command line arguments. - # args: -v - - # Optional: show only new issues if it's a pull request. The default value is `false`. - only-new-issues: true - - goreportcard: - runs-on: ubuntu-latest - if: github.event_name == 'push' - steps: - - name: Go report card - uses: creekorful/goreportcard-action@v1.0 - - sonarcloud: - needs: test - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - with: - # Disabling shallow clone is recommended for improving relevancy of reporting - fetch-depth: 0 - - name: Download unit tests report - uses: actions/download-artifact@v2 - with: - name: report - - name: Download code coverage results - uses: actions/download-artifact@v2 - with: - name: coverage - - name: SonarCloud Scan - uses: sonarsource/sonarcloud-github-action@master - with: - args: > - -Dproject.settings=./.sonar-project.properties - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 5cba792..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: release - -on: - push: - tags: - # Push events to matching v#.#.#*, ex: v1.2.3, v.2.4.6-beta - - 'v[0-9]+.[0-9]+.[0-9]+*' - -jobs: - release: - runs-on: [ ubuntu-latest ] - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - name: Prepare Release Body - id: prep - run: | - export VERSION=${GITHUB_REF#refs/tags/} - export NOTES=$(cat CHANGELOG.md | perl -0777 -ne 'print "$1\n" if /.*## \[${VERSION}\]\s(.*?)\s+## \[(v\d+.\d+.\d+)\].*/s') - export TODAY=`date +'%m/%d/%Y'` - echo ::set-output name=rname::$(echo ${VERSION} ${TODAY}) - echo ::set-output name=body::${NOTES} - - name: create release - id: create_release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token - with: - tag_name: ${{ github.ref }} - draft: false - prerelease: false - release_name: ${{ steps.prep.outputs.rname }} - body: ${{ steps.prep.outputs.body }} diff --git a/.github/workflows/tag.yml b/.github/workflows/tag.yml deleted file mode 100644 index 641cfcc..0000000 --- a/.github/workflows/tag.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: tag - -on: - push: - paths: - - "CHANGELOG.md" # only try to tag if the CHANGELOG has been updated. - branches: - - main - -jobs: - build: - runs-on: [ ubuntu-latest ] - steps: - - uses: actions/checkout@v2 - with: - token: '${{ secrets.PERSONAL_ACCESS_TOKEN }}' - fetch-depth: 0 - - name: set up bot - run: | - git config --global user.name "xmidt-bot" - git config --global user.email "$BOT_EMAIL" - - name: export variables and tag commit - run: | - export OLD_VERSION=$(git describe --tags `git rev-list --tags --max-count=1` | tail -1) - export TAG=$(cat CHANGELOG.md | perl -0777 -ne 'print "$1" if /.*## \[Unreleased\]\s+## \[(v\d+.\d+.\d+)\].*/s') - export TODAY=`date +'%m/%d/%Y'` - export NOTES=$(cat CHANGELOG.md | perl -0777 -ne 'print "$ENV{TODAY}\n\n$1\n" if /.*## \[$ENV{TAG}\]\s(.*?)\s+## \[(v\d+.\d+.\d+)\].*/s') - if [[ "$TAG" != "" && "$TAG" != "$OLD_VERSION" ]]; then git tag -a "$TAG" -m "$NOTES"; git push origin --tags; echo $?; fi diff --git a/.github/workflows/updater.yml b/.github/workflows/updater.yml new file mode 100644 index 0000000..ef5876f --- /dev/null +++ b/.github/workflows/updater.yml @@ -0,0 +1,15 @@ +# SPDX-FileCopyrightText: 2022 Comcast Cable Communications Management, LLC +# SPDX-License-Identifier: Apache-2.0 +--- +name: Dependency Updater + +on: + schedule: + # Run every week 9:05 AM UTC (Monday at 1:00 AM PT) + - cron: '05 9 * * 1' + workflow_dispatch: + +jobs: + ci: + uses: xmidt-org/.github/.github/workflows/go-updater.yml@go-updater-v1 + secrets: inherit diff --git a/.sonar-project.properties b/.sonar-project.properties deleted file mode 100644 index 41cf428..0000000 --- a/.sonar-project.properties +++ /dev/null @@ -1,34 +0,0 @@ -# Reference: -# https://github.com/SonarSource/sonarcloud_example_go-sqscanner-travis/blob/master/sonar-project.properties - - -# ===================================================== -# Standard properties -# ===================================================== - -sonar.organization=xmidt-org -sonar.projectKey=xmidt-org_medley -sonar.projectName=medley - -sonar.sources=. -sonar.exclusions=**/*_test.go,**/vendor/** - -sonar.tests=. -sonar.test.inclusions=**/*_test.go -sonar.test.exclusions=**/vendor/** - -# ===================================================== -# Meta-data for the project -# ===================================================== - -sonar.links.homepage=https://github.com/xmidt-org/medley -sonar.links.ci=https://github.com/xmidt-org/medley/actions -sonar.links.scm=https://github.com/xmidt-org/medley -sonar.links.issue=https://github.com/xmidt-org/medley/issues - -# ===================================================== -# Properties specific to Go -# ===================================================== - -sonar.go.tests.reportPaths=report.json -sonar.go.coverage.reportPaths=coverage.txt diff --git a/README.md b/README.md index 77c8628..22affa4 100644 --- a/README.md +++ b/README.md @@ -2,13 +2,14 @@ medley does something good. -[![Build Status](https://travis-ci.com/xmidt-org/medley.svg?branch=main)](https://travis-ci.com/xmidt-org/medley) +[![Build Status](https://github.com/xmidt-org/medley/actions/workflows/ci.yml/badge.svg)](https://github.com/xmidt-org/medley/actions/workflows/ci.yml) +[![Dependency Updateer](https://github.com/xmidt-org/medley/actions/workflows/updater.yml/badge.svg)](https://github.com/xmidt-org/medley/actions/workflows/updater.yml) [![codecov.io](http://codecov.io/github/xmidt-org/medley/coverage.svg?branch=main)](http://codecov.io/github/xmidt-org/medley?branch=main) [![Go Report Card](https://goreportcard.com/badge/github.com/xmidt-org/medley)](https://goreportcard.com/report/github.com/xmidt-org/medley) +[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=xmidt-org_medley&metric=alert_status)](https://sonarcloud.io/dashboard?id=xmidt-org_medley) [![Apache V2 License](http://img.shields.io/badge/license-Apache%20V2-blue.svg)](https://github.com/xmidt-org/medley/blob/main/LICENSE) -[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=xmidt-org_PROJECT&metric=alert_status)](https://sonarcloud.io/dashboard?id=xmidt-org_PROJECT) -[![GitHub release](https://img.shields.io/github/release/xmidt-org/medley.svg)](CHANGELOG.md) -[![PkgGoDev](https://pkg.go.dev/badge/github.com/xmidt-org/medley)](https://pkg.go.dev/github.com/xmidt-org/medley) +[![GitHub Release](https://img.shields.io/github/release/xmidt-org/medley.svg)](CHANGELOG.md) +[![GoDoc](https://pkg.go.dev/badge/github.com/xmidt-org/medley)](https://pkg.go.dev/github.com/xmidt-org/medley) ## Setup