Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into replSetGetConfigColle…
Browse files Browse the repository at this point in the history
…ctor

# Conflicts:
#	README.md
#	exporter/exporter.go
#	main.go
#	main_test.go
  • Loading branch information
hiroshi committed Feb 24, 2023
2 parents bb9ecc8 + b526414 commit e2545b1
Show file tree
Hide file tree
Showing 68 changed files with 4,518 additions and 1,346 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1 +1 @@

* @percona/pmm-review-exporters
31 changes: 31 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
name: Bug report
about: Create a report to help us improve the exporter
title: ''
labels: ["community", "bug", "triage"]
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.
If the issue relates to PMM, please open [JIRA PMM](https://jira.percona.com/projects/PMM/issues) issue instead of GH issue.

**To Reproduce**
Steps to reproduce the behavior:
1. what parameters are being passed to `mongodb_exporter`
2. describe steps to reproduce the issue

**Expected behavior**
A clear and concise description of what you expected to happen.

**Logs**
Please provide logs relevant to the issue

**Environment**
- OS,
- environment (docker, k8s, etc)
- MongoDB version

**Additional context**
Add any other context about the problem here.
21 changes: 21 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ["community", "enhancement", "triage"]
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
If the improvement is related to PMM, please open [PMM project](https://jira.percona.com/projects/PMM/issues) feature instead of GH feature request.

**Describe the solution you'd like**
A clear and concise description of what you expect to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots related to the feature request here.
72 changes: 39 additions & 33 deletions .github/check-license.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,53 +21,61 @@
package main

import (
"bufio"
"flag"
"fmt"
"io"
"log"
"os"
"path/filepath"
"regexp"
"runtime"
)

func getHeader() string {
_, file, _, ok := runtime.Caller(0)
if !ok {
panic("runtime.Caller(0) failed")
}
f, err := os.Open(file)
if err != nil {
log.Fatal(err)
}
defer f.Close()
var (
generatedHeader = regexp.MustCompile(`^// Code generated .* DO NOT EDIT\.`)

var header string
s := bufio.NewScanner(f)
for s.Scan() {
if s.Text() == "" {
break
}
header += s.Text() + "\n"
}
header += "\n"
if err := s.Err(); err != nil {
log.Fatal(err)
}
return header
}
copyrightText = `// mongodb_exporter
// Copyright (C) 2022 Percona LLC
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
`

var generatedHeader = regexp.MustCompile(`^// Code generated .* DO NOT EDIT\.`)
copyrightPattern = regexp.MustCompile(`^// mongodb_exporter
// Copyright \(C\) 20\d{2} Percona LLC
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// \(at your option\) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
`)
)

func checkHeader(path string, header string) bool {
func checkHeader(path string) bool {
f, err := os.Open(path)
if err != nil {
log.Fatal(err)
}
defer f.Close()

actual := make([]byte, len(header))
actual := make([]byte, len(copyrightText))
_, err = io.ReadFull(f, actual)
if err == io.ErrUnexpectedEOF {
err = nil // some files are shorter than license header
Expand All @@ -81,7 +89,7 @@ func checkHeader(path string, header string) bool {
return true
}

if header != string(actual) {
if !copyrightPattern.Match(actual) {
log.Print(path)
return false
}
Expand All @@ -96,8 +104,6 @@ func main() {
}
flag.Parse()

header := getHeader()

ok := true
filepath.Walk(".", func(path string, info os.FileInfo, err error) error {
if err != nil {
Expand All @@ -113,7 +119,7 @@ func main() {
}

if filepath.Ext(info.Name()) == ".go" {
if !checkHeader(path, header) {
if !checkHeader(path) {
ok = false
}
}
Expand Down
4 changes: 4 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ updates:
directory: "/tools"
schedule:
interval: "weekly"
- package-ecosystem: "docker"
directory: "/"
schedule:
interval: "weekly"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
Expand Down
5 changes: 3 additions & 2 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
[PMM-XXXX](https://jira.percona.com/browse/PMM-XXXX) (optional, if ticket reported)

- [ ] Links to other linked pull requests (optional).

---

- [ ] Tests passed.
- [ ] Fix conflicts with target branch.
- [ ] Update jira ticket description if needed.
- [ ] Attach screenshots/console output to confirm new behavior to jira ticket, if applicable.


When all checks have passed and code is ready for the review, bot should add `pmm-review-exporters` team as the reviewer. That would assign people from the review team automatically. Report any issues on our [Forums](https://forums.percona.com) and [Discord](https://discord.gg/mQEyGPkNbR).
Once all checks pass and the code is ready for review, please add `pmm-review-exporters` team as the reviewer. That would assign people from the review team automatically. Report any issues on our [Forum](https://forums.percona.com) or [Discord](https://per.co.na/discord).
15 changes: 8 additions & 7 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,22 @@ jobs:
fail-fast: false
matrix:
go-version:
- 1.16.x
- 1.19.x
image:
- mongo:3.6
- mongo:4.0
- mongo:4.2
- mongo:4.4
- percona/percona-server-mongodb:3.6
- percona/percona-server-mongodb:4.0
- mongo:5.0
- percona/percona-server-mongodb:4.2
- percona/percona-server-mongodb:4.4
- percona/percona-server-mongodb:5.0
os: [ubuntu-latest]
may-fail: [false]

include:
# test only one image on tip to detect major Go changes earlier
# without wasting too much time on CI
- go-version: tip
image: mongo:4.2
image: mongo:4.4
os: ubuntu-latest
may-fail: true

Expand All @@ -60,13 +59,14 @@ jobs:
echo "$HOME/gotip/bin" >> $GITHUB_PATH
- name: Check out code into the Go module directory
uses: percona-platform/checkout@v2
uses: percona-platform/checkout@v3

- name: Initialize dependencies and linters
run: |
make init
- name: Diff
if: startsWith( ${{ matrix.go-version }}, '1.17')
run: |
make format
git diff --exit-code
Expand All @@ -82,3 +82,4 @@ jobs:
# use GITHUB_TOKEN because only it has access to GitHub Checks API
bin/golangci-lint run -c=.golangci-required.yml --out-format=line-number | env REVIEWDOG_GITHUB_API_TOKEN=${{ secrets.GITHUB_TOKEN }} bin/reviewdog -f=golangci-lint -level=error -reporter=github-pr-check
bin/golangci-lint run -c=.golangci.yml --out-format=line-number | env REVIEWDOG_GITHUB_API_TOKEN=${{ secrets.GITHUB_TOKEN }} bin/reviewdog -f=golangci-lint -level=error -reporter=github-pr-review
make check-license
15 changes: 0 additions & 15 deletions .github/workflows/ready-for-review.yml

This file was deleted.

32 changes: 28 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
# run when new tag is pushed
tags:
- v0.2*
- v*
# manually trigger the release
workflow_dispatch:
jobs:
Expand All @@ -13,17 +13,41 @@ jobs:
steps:
-
name: Checkout
uses: percona-platform/checkout@v2
uses: percona-platform/checkout@v3
with:
fetch-depth: 0
-
name: Set up Go
uses: percona-platform/setup-go@v2
with:
go-version: 1.16
go-version: 1.19
-
name: Login to Docker Hub
uses: percona-platform/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

-
name: Login to GitHub Container Registry
uses: percona-platform/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

-
name: Set up QEMU
uses: docker/setup-qemu-action@v2

-
name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2

-
name: Run GoReleaser
uses: percona-platform/goreleaser-action@v2
uses: percona-platform/goreleaser-action@v3
with:
version: latest
args: release --rm-dist
Expand Down
7 changes: 6 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ linters:
- unused
- testpackage
- wsl

- exhaustivestruct
- varnamelen
- maligned #deprecated
- scopelint #deprecated
- golint #deprecated
- interfacer #deprecated
issues:
exclude-use-default: false
exclude:
Expand Down
Loading

0 comments on commit e2545b1

Please sign in to comment.