From 79b8314617a3a61b12c132ec90c687a70e178425 Mon Sep 17 00:00:00 2001
From: Luca Comellini <luca.com@gmail.com>
Date: Tue, 3 Dec 2024 17:44:19 -0800
Subject: [PATCH] Add common workflows and files (#8)

---
 .editorconfig                           | 13 ++++++
 .github/release.yml                     | 29 ++++++++++++
 .github/workflows/ci.yml                | 61 +++++++++++++++++++++++++
 .github/workflows/codeql.yml            | 53 +++++++++++++++++++++
 .github/workflows/dependency-review.yml | 22 +++++++++
 .github/workflows/labeler.yml           | 26 +++++++++++
 .travis.yml                             | 13 ------
 README.md                               |  9 ++--
 8 files changed, 209 insertions(+), 17 deletions(-)
 create mode 100644 .editorconfig
 create mode 100644 .github/release.yml
 create mode 100644 .github/workflows/ci.yml
 create mode 100644 .github/workflows/codeql.yml
 create mode 100644 .github/workflows/dependency-review.yml
 create mode 100644 .github/workflows/labeler.yml
 delete mode 100644 .travis.yml

diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..302cfc4
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,13 @@
+root = true
+
+[*]
+charset = utf-8
+end_of_line = lf
+insert_final_newline = true
+trim_trailing_whitespace = true
+indent_size = 4
+indent_style = tab
+
+[*.{md,yml,yaml}]
+indent_size = 2
+indent_style = space
diff --git a/.github/release.yml b/.github/release.yml
new file mode 100644
index 0000000..ceb3c63
--- /dev/null
+++ b/.github/release.yml
@@ -0,0 +1,29 @@
+changelog:
+  exclude:
+    labels:
+      - skip changelog
+  categories:
+    - title: ๐Ÿ’ฃ Breaking Changes
+      labels:
+        - change
+    - title: ๐Ÿš€ Features
+      labels:
+        - enhancement
+    - title: ๐Ÿ› Bug Fixes
+      labels:
+        - bug
+    - title: ๐Ÿงช Tests
+      labels:
+        - tests
+    - title: ๐Ÿ”จ Maintenance
+      labels:
+        - chore
+    - title: ๐Ÿ“ Documentation
+      labels:
+        - documentation
+    - title: โฌ†๏ธ Dependencies
+      labels:
+        - dependencies
+    - title: Other Changes
+      labels:
+        - "*"
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
new file mode 100644
index 0000000..d99ad59
--- /dev/null
+++ b/.github/workflows/ci.yml
@@ -0,0 +1,61 @@
+name: CI
+
+on:
+  push:
+    branches:
+      - master
+    tags:
+      - "v[0-9]+.[0-9]+.[0-9]+*"
+  pull_request:
+    branches:
+      - master
+
+jobs:
+  build:
+    runs-on: ubuntu-24.04
+    steps:
+      - name: Checkout Repository
+        uses: actions/checkout@v4
+
+      - name: Setup Golang Environment
+        uses: actions/setup-go@v5
+        with:
+          go-version: stable
+
+      - name: Build
+        run: go build -v ./...
+
+  test:
+    runs-on: ubuntu-24.04
+    strategy:
+      fail-fast: false
+      matrix:
+        go-version: [
+          oldstable,
+          stable,
+          ]
+    steps:
+      - name: Checkout Repository
+        uses: actions/checkout@v4
+
+      - name: Setup Golang Environment
+        uses: actions/setup-go@v5
+        with:
+          go-version: ${{ matrix.go-version }}
+
+      - name: Run Unit Tests
+        run: go test -v -cover -race -shuffle=on ./...
+
+  draft-release:
+    runs-on: ubuntu-24.04
+    if: github.event_name != 'pull_request'
+    steps:
+      - name: Checkout Repository
+        uses: actions/checkout@v4
+
+      - name: Create/Update Draft Release
+        uses: lucacome/draft-release@v1.1.1
+        with:
+          minor-label: "enhancement"
+          major-label: "change"
+          collapse-after: 20
diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml
new file mode 100644
index 0000000..e180b49
--- /dev/null
+++ b/.github/workflows/codeql.yml
@@ -0,0 +1,53 @@
+name: "CodeQL"
+
+on:
+  push:
+    branches:
+      - master
+  pull_request:
+    branches:
+      - master
+  schedule:
+    - cron: '32 21 * * 0'
+
+concurrency:
+  group: ${{ github.ref_name }}-codeql
+  cancel-in-progress: true
+
+jobs:
+  analyze:
+    name: Analyze (${{ matrix.language }})
+    runs-on: ubuntu-24.04
+    permissions:
+      # required for all workflows
+      security-events: write
+
+      # required to fetch internal or private CodeQL packs
+      packages: read
+
+      # only required for workflows in private repositories
+      actions: read
+      contents: read
+
+    strategy:
+      fail-fast: false
+      matrix:
+        include:
+        - language: go
+          build-mode: autobuild
+    steps:
+    - name: Checkout repository
+      uses: actions/checkout@v4
+
+    # Initializes the CodeQL tools for scanning.
+    - name: Initialize CodeQL
+      uses: github/codeql-action/init@v3
+      with:
+        languages: ${{ matrix.language }}
+        build-mode: ${{ matrix.build-mode }}
+        queries: security-and-quality
+
+    - name: Perform CodeQL Analysis
+      uses: github/codeql-action/analyze@v3
+      with:
+        category: "/language:${{matrix.language}}"
diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml
new file mode 100644
index 0000000..5edf885
--- /dev/null
+++ b/.github/workflows/dependency-review.yml
@@ -0,0 +1,22 @@
+name: Dependency review
+on:
+  pull_request:
+    branches: 
+      - master
+
+permissions:
+  contents: read
+  # Write permissions for pull-requests are required for using the `comment-summary-in-pr` option, comment out if you aren't using this option
+  pull-requests: write
+
+jobs:
+  dependency-review:
+    runs-on: ubuntu-24.04
+    steps:
+      - name: Checkout Repository
+        uses: actions/checkout@v4
+        
+      - name: Dependency Review
+        uses: actions/dependency-review-action@v4
+        with:
+          config-file: "opentracing-contrib/common/dependency-review-config.yml@main"
diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml
new file mode 100644
index 0000000..ae6ccc7
--- /dev/null
+++ b/.github/workflows/labeler.yml
@@ -0,0 +1,26 @@
+name: Pull Request Labeler
+on:
+  - pull_request_target
+
+permissions:
+  contents: read
+
+jobs:
+  triage:
+    permissions:
+      contents: read
+      pull-requests: write
+    runs-on: ubuntu-24.04
+    steps:
+      - uses: actions/checkout@v4
+        with:
+          sparse-checkout: |
+            labeler.yml
+          sparse-checkout-cone-mode: false
+          repository: opentracing-contrib/common
+
+      - uses: actions/labeler@v5
+        with:
+          repo-token: "${{ secrets.GITHUB_TOKEN }}"
+          sync-labels: true
+          configuration-path: labeler.yml
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 185c179..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,13 +0,0 @@
-language: go
-
-go:
-  - 1.8.x
-  - 1.9.x
-  - tip
-
-install:
-  - go get -d -t github.com/opentracing-contrib/go-amqp/...
-  - go get -u github.com/golang/lint/...
-script:
-  - make test lint
-  - go build ./...
diff --git a/README.md b/README.md
index 1e8a79a..2056ee2 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,8 @@
 # go-amqp
 
-[![Build Status]](https://travis-ci.org/opentracing-contrib/go-amqp)
+[![CI](https://github.com/opentracing-contrib/go-amqp/actions/workflows/ci.yml/badge.svg)](https://github.com/opentracing-contrib/go-amqp/actions/workflows/ci.yml)
+[![Go Report Card](https://goreportcard.com/badge/github.com/opentracing-contrib/go-amqp)](https://goreportcard.com/report/github.com/opentracing-contrib/go-amqp)
+![GitHub go.mod Go version](https://img.shields.io/github/go-mod/go-version/opentracing-contrib/go-amqp)
 [![GoDoc]](http://godoc.org/github.com/opentracing-contrib/go-amqp/amqptracer)
 
 [AMQP] instrumentation in Go
@@ -31,7 +33,7 @@ Here are the example serialization and deserialization of the `opentracing`
 `SapnContext` over the AMQP broker so that we can visualize the tracing
 between the producers and the consumers.
 
-#### Serializing to the wire
+### Serializing to the wire
 
 ```go
     func PublishMessage(
@@ -53,7 +55,7 @@ between the producers and the consumers.
     }
 ```
 
-#### Deserializing from the wire
+### Deserializing from the wire
 
 ```go
     func ConsumeMessage(ctx context.Context, msg *amqp.Delivery) error {
@@ -77,6 +79,5 @@ between the producers and the consumers.
 [terminology]: http://opentracing.io/documentation/pages/spec.html
 [OpenTracing API for Go]: https://github.com/opentracing/opentracing-go
 [AMQP]: https://github.com/streadway/amqp
-[Build Status]: https://travis-ci.org/opentracing-contrib/go-amqp.svg
 [GoDoc]: https://godoc.org/github.com/opentracing-contrib/go-amqp/amqptracer?status.svg
 [check godoc]: https://godoc.org/github.com/opentracing-contrib/go-amqp/amqptracer