Skip to content

Commit

Permalink
Merge branch 'main' into feature/csuzhang_add_contributing.md
Browse files Browse the repository at this point in the history
  • Loading branch information
hanyuancheung authored Jun 30, 2023
2 parents 6fc9421 + cb5be8f commit 6f6bf47
Show file tree
Hide file tree
Showing 129 changed files with 3,618 additions and 1,775 deletions.
16 changes: 16 additions & 0 deletions .chloggen/TEMPLATE.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type:

# The name of the component, or a single word describing the area of concern, (e.g. crosslink)
component:

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note:

# One or more tracking issues related to the change
issues: []

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:
16 changes: 16 additions & 0 deletions .chloggen/chloggen-disallow-empty-strings.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: bug_fix

# The name of the component, or a single word describing the area of concern, (e.g. crosslink)
component: chloggen

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Disallow whitespace-only values

# One or more tracking issues related to the change
issues: [164]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:
4 changes: 1 addition & 3 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,4 @@
#
# For anything not explicitly taken by someone else:

* @open-telemetry/go-maintainers @open-telemetry/collector-maintainers

chloggen/ @open-telemetry/go-maintainers @open-telemetry/collector-maintainers @open-telemetry/collector-contrib-approvers
* @open-telemetry/go-maintainers @open-telemetry/go-approvers @open-telemetry/collector-maintainers @open-telemetry/collector-approvers @open-telemetry/collector-contrib-maintainer @open-telemetry/collector-contrib-approvers
9 changes: 9 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@ updates:
schedule:
interval: weekly
day: sunday
- package-ecosystem: gomod
directory: /gotmpl
labels:
- dependencies
- go
- Skip Changelog
schedule:
interval: weekly
day: sunday
- package-ecosystem: gomod
directory: /internal/tools
labels:
Expand Down
83 changes: 83 additions & 0 deletions .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# This action requires that any PR targeting the main branch should add a
# yaml file to the ./.chloggen/ directory. If a CHANGELOG entry is not required,
# or if performing maintance on the Changelog, add either \"[chore]\" to the title of
# the pull request or add the \"Skip Changelog\" label to disable this action.

name: changelog

on:
pull_request:
types: [opened, synchronize, reopened, labeled, unlabeled]
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref }}
cancel-in-progress: true

jobs:
changelog:
runs-on: ubuntu-latest
if: ${{ !contains(github.event.pull_request.labels.*.name, 'dependencies') && !contains(github.event.pull_request.labels.*.name, 'Skip Changelog') && !contains(github.event.pull_request.title, '[chore]')}}

steps:
- name: Checkout Repo
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: 1.19
- name: Cache Go
id: go-cache
uses: actions/cache@v3
with:
path: |
~/go/bin
~/go/pkg/mod
key: changelog-${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}

- name: Ensure no changes to the CHANGELOG
run: |
if [[ $(git diff --name-only $(git merge-base origin/main ${{ github.event.pull_request.head.sha }}) ${{ github.event.pull_request.head.sha }} ./CHANGELOG.md) ]]
then
echo "The CHANGELOG should not be directly modified."
echo "Please add a .yaml file to the ./.chloggen/ directory."
echo "Run make chlog-new to add a new changelog file."
echo "Alternately, add either \"[chore]\" to the title of the pull request or add the \"Skip Changelog\" label if this job should be skipped."
false
else
echo "The CHANGELOG was not modified."
fi
- name: Ensure ./.chloggen/*.yaml addition(s)
run: |
if [[ 1 -gt $(git diff --diff-filter=A --name-only $(git merge-base origin/main ${{ github.event.pull_request.head.sha }}) ${{ github.event.pull_request.head.sha }} ./.chloggen | grep -c \\.yaml) ]]
then
echo "No changelog entry was added to the ./.chloggen/ directory."
echo "Please add a .yaml file to the ./.chloggen/ directory."
echo "Run make chlog-new to add a new changelog file."
echo "Alternately, add either \"[chore]\" to the title of the pull request or add the \"Skip Changelog\" label if this job should be skipped."
false
else
echo "A changelog entry was added to the ./.chloggen/ directory."
fi
- name: Validate ./.chloggen/*.yaml changes
run: |
make chlog-validate \
|| { echo "New ./.chloggen/*.yaml file failed validation."; exit 1; }
# In order to validate any links in the yaml file, render the config to markdown
- name: Render .chloggen changelog entries
run: make chlog-preview > changelog_preview.md
- name: Install markdown-link-check
run: npm install -g markdown-link-check
- name: Run markdown-link-check
run: |
markdown-link-check \
--verbose \
--config .github/workflows/check_links_config.json \
changelog_preview.md \
|| { echo "Check that anchor links are lowercase"; exit 1; }
17 changes: 17 additions & 0 deletions .github/workflows/check_links_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"ignorePatterns": [
{
"pattern": "http(s)?://\\d+\\.\\d+\\.\\d+\\.\\d+"
},
{
"pattern": "http(s)?://localhost"
},
{
"pattern": "http(s)?://example.com"
},
{
"pattern": "^#"
}
],
"aliveStatusCodes": [429, 200]
}
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ env:
# Path to where test results will be saved.
TEST_RESULTS: /tmp/test-results
# Default minimum version of Go to support.
DEFAULT_GO_VERSION: 1.18
DEFAULT_GO_VERSION: 1.19
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version: ${{ env.DEFAULT_GO_VERSION }}
- name: Checkout Repo
Expand Down Expand Up @@ -48,7 +48,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version: ${{ env.DEFAULT_GO_VERSION }}
- name: Checkout Repo
Expand All @@ -71,7 +71,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version: ${{ env.DEFAULT_GO_VERSION }}
- name: Checkout Repo
Expand All @@ -95,7 +95,7 @@ jobs:
cp coverage.txt $TEST_RESULTS
cp coverage.html $TEST_RESULTS
- name: Upload coverage report
uses: codecov/[email protected].0
uses: codecov/[email protected].4
with:
file: ./coverage.txt
fail_ci_if_error: true
Expand Down
23 changes: 23 additions & 0 deletions .github/workflows/create-dependabot-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Automation - Dependabot PR

on:
workflow_dispatch:

jobs:
create-pr:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Install zsh
run: sudo apt-get update; sudo apt-get install zsh

- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: 1.19

- name: Run dependabot-pr.sh
run: ./.github/workflows/scripts/dependabot-pr.sh
env:
GITHUB_TOKEN: ${{ secrets.OPENTELEMETRYBOT_GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
- uses: actions/setup-go@v3
- uses: actions/setup-go@v4
with:
go-version: '^1.15.0'
- uses: evantorrie/mott-the-tidier@v1-beta
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/markdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Get changed files
id: changes
run: |
echo "::set-output name=md::$(git diff --name-only --diff-filter=ACMRTUXB origin/${{ github.event.pull_request.base.ref }} ${{ github.event.pull_request.head.sha }} | grep .md$ | xargs)"
echo "md=$(git diff --name-only --diff-filter=ACMRTUXB origin/${{ github.event.pull_request.base.ref }} ${{ github.event.pull_request.head.sha }} | grep .md$ | xargs)" >> $GITHUB_OUTPUT
lint:
name: lint markdown files
Expand All @@ -32,6 +32,7 @@ jobs:
uses: docker://avtodev/markdown-lint:v1
with:
args: -i "/**/testdata" ${{needs.changedfiles.outputs.md}}
ignore: 'CHANGELOG.md'

check-links:
runs-on: ubuntu-latest
Expand Down
61 changes: 61 additions & 0 deletions .github/workflows/scripts/dependabot-pr.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/bin/zsh -ex

# Copyright The OpenTelemetry Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

git config user.name opentelemetrybot
git config user.email [email protected]

PR_NAME=dependabot-prs/`date +'%Y-%m-%dT%H%M%S'`
git checkout -b $PR_NAME

IFS=$'\n'
requests=($( gh pr list --search "author:app/dependabot" --json title --jq '.[].title' ))
message=""
dirs=(`find . -type f -name "go.mod" -exec dirname {} \; | sort | egrep '^./'`)

declare -A mods

for line in $requests; do
echo $line
if [[ $line != Bump* ]]; then
continue
fi

module=$(echo $line | cut -f 2 -d " ")
version=$(echo $line | cut -f 6 -d " ")

mods[$module]=$version
message+=$line
message+=$'\n'
done

for module version in ${(kv)mods}; do
topdir=`pwd`
for dir in $dirs; do
echo "checking $dir"
cd $dir && if grep -q "$module " go.mod; then go get "$module"@v"$version"; fi
cd $topdir
done
done

make tidy lint build

git add go.sum go.mod
git add "**/go.sum" "**/go.mod"
git commit -m "dependabot updates `date`
$message"
git push origin $PR_NAME

gh pr create --title "[chore] dependabot updates `date`" --body "$message"
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,17 @@ Thumbs.db
*.iml
*.so
coverage.*
/go.work
go.work.sum

crosslink/internal/test_data/
!crosslink/internal/test_data/.placeholder

checkdoc/checkdoc
chloggen/chloggen
crosslink/crosslink
dbotconf/dbotconf
issuegenerator/issuegenerator
gotmpl/gotmpl
multimod/multimod
semconvgen/semconvgen
21 changes: 15 additions & 6 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,21 @@ linters-settings:
- kilometres

depguard:
list-type: denylist
include-go-root: true
packages-with-error-message:
# See https://github.com/open-telemetry/opentelemetry-collector/issues/5200 for rationale
- sync/atomic: "Use go.uber.org/atomic instead of sync/atomic"
- github.com/pkg/errors: "Use 'errors' or 'fmt' instead of github.com/pkg/errors"
rules:
main:
deny:
# See https://github.com/open-telemetry/opentelemetry-collector/issues/5200 for rationale
- pkg: "sync/atomic"
desc: "Use go.uber.org/atomic instead of sync/atomic"
- pkg: "github.com/pkg/errors"
desc: "Use 'errors' or 'fmt' instead of github.com/pkg/errors"
non-tests:
files:
- "!$test"
- "!**/*test/*.go"
deny:
- pkg: "testing"
- pkg: "github.com/stretchr/testify"

linters:
enable:
Expand Down
7 changes: 7 additions & 0 deletions .markdownlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Default state for all rules
default: true

# Configure long lines for tables and code blocks
MD013:
code_blocks: false
tables: false
Loading

0 comments on commit 6f6bf47

Please sign in to comment.