Skip to content

Commit

Permalink
Update CI configs to master (#76)
Browse files Browse the repository at this point in the history
Update lint scripts and CI configs.
  • Loading branch information
pionbot authored Jan 20, 2023
1 parent 9679449 commit 6d600d2
Show file tree
Hide file tree
Showing 10 changed files with 108 additions and 318 deletions.
1 change: 1 addition & 0 deletions .github/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.goassets
29 changes: 29 additions & 0 deletions .github/fetch-scripts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/sh

#
# DO NOT EDIT THIS FILE
#
# It is automatically copied from https://github.com/pion/.goassets repository.
#
# If you want to update the shared CI config, send a PR to
# https://github.com/pion/.goassets instead of this repository.
#

set -eu

SCRIPT_PATH="$(realpath "$(dirname "$0")")"
GOASSETS_PATH="${SCRIPT_PATH}/.goassets"

GOASSETS_REF=${GOASSETS_REF:-master}

if [ -d "${GOASSETS_PATH}" ]; then
if ! git -C "${GOASSETS_PATH}" diff --exit-code; then
echo "${GOASSETS_PATH} has uncommitted changes" >&2
exit 1
fi
git -C "${GOASSETS_PATH}" fetch origin
git -C "${GOASSETS_PATH}" checkout ${GOASSETS_REF}
git -C "${GOASSETS_PATH}" reset --hard origin/${GOASSETS_REF}
else
git clone -b ${GOASSETS_REF} https://github.com/pion/.goassets.git "${GOASSETS_PATH}"
fi
15 changes: 7 additions & 8 deletions .github/install-hooks.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh

#
# DO NOT EDIT THIS FILE
Expand All @@ -9,11 +9,10 @@
# https://github.com/pion/.goassets instead of this repository.
#

SCRIPT_PATH=$(
cd "$(dirname "${BASH_SOURCE[0]}")"
pwd -P
)
SCRIPT_PATH="$(realpath "$(dirname "$0")")"

cp "${SCRIPT_PATH}/hooks/commit-msg.sh" "${SCRIPT_PATH}/../.git/hooks/commit-msg"
cp "${SCRIPT_PATH}/hooks/pre-commit.sh" "${SCRIPT_PATH}/../.git/hooks/pre-commit"
cp "${SCRIPT_PATH}/hooks/pre-push.sh" "${SCRIPT_PATH}/../.git/hooks/pre-push"
. ${SCRIPT_PATH}/fetch-scripts.sh

cp "${GOASSETS_PATH}/hooks/commit-msg.sh" "${SCRIPT_PATH}/../.git/hooks/commit-msg"
cp "${GOASSETS_PATH}/hooks/pre-commit.sh" "${SCRIPT_PATH}/../.git/hooks/pre-commit"
cp "${GOASSETS_PATH}/hooks/pre-push.sh" "${SCRIPT_PATH}/../.git/hooks/pre-push"
39 changes: 13 additions & 26 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
name: "CodeQL"
#
# DO NOT EDIT THIS FILE
#
# It is automatically copied from https://github.com/pion/.goassets repository.
# If this repository should have package specific CI config,
# remove the repository name from .goassets/.github/workflows/assets-sync.yml.
#
# If you want to update the shared CI config, send a PR to
# https://github.com/pion/.goassets instead of this repository.
#

name: CodeQL

on:
workflow_dispatch:
Expand All @@ -12,28 +23,4 @@ on:

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

steps:
- name: Checkout repo
uses: actions/checkout@v3

# The code in examples/ might intentionally do things like log credentials
# in order to show how the library is used, aid in debugging etc. We
# should ignore those for CodeQL scanning, and only focus on the package
# itself.
- name: Remove example code
run: rm -rf examples/

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: 'go'

- name: CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: pion/.goassets/.github/workflows/codeql-analysis.reusable.yml@master
65 changes: 5 additions & 60 deletions .github/workflows/generate-authors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,68 +9,13 @@
# https://github.com/pion/.goassets instead of this repository.
#

name: generate-authors
name: Generate Authors

on:
pull_request:

jobs:
checksecret:
permissions:
contents: none
runs-on: ubuntu-latest
if: startsWith(github.event.pull_request.head.ref, 'renovate/') == false
outputs:
is_PIONBOT_PRIVATE_KEY_set: ${{ steps.checksecret_job.outputs.is_PIONBOT_PRIVATE_KEY_set }}
steps:
- id: checksecret_job
env:
PIONBOT_PRIVATE_KEY: ${{ secrets.PIONBOT_PRIVATE_KEY }}
run: |
echo "is_PIONBOT_PRIVATE_KEY_set: ${{ env.PIONBOT_PRIVATE_KEY != '' }}"
echo "::set-output name=is_PIONBOT_PRIVATE_KEY_set::${{ env.PIONBOT_PRIVATE_KEY != '' }}"
generate-authors:
permissions:
contents: write
needs: [checksecret]
if: needs.checksecret.outputs.is_PIONBOT_PRIVATE_KEY_set == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
fetch-depth: 0
token: ${{ secrets.PIONBOT_PRIVATE_KEY }}

- name: Generate the authors file
run: .github/generate-authors.sh

- name: Add the authors file to git
run: git add AUTHORS.txt

- name: Get last commit message
id: last-commit-message
run: |
COMMIT_MSG=$(git log -1 --pretty=%B)
COMMIT_MSG="${COMMIT_MSG//'%'/'%25'}"
COMMIT_MSG="${COMMIT_MSG//$'\n'/'%0A'}"
COMMIT_MSG="${COMMIT_MSG//$'\r'/'%0D'}"
echo "::set-output name=msg::$COMMIT_MSG"
- name: Get last commit author
id: last-commit-author
run: echo "::set-output name=msg::$(git log -1 --pretty='%aN <%ae>')"

- name: Check if AUTHORS.txt file has changed
id: git-status-output
run: echo "::set-output name=msg::$(git status -s | wc -l)"

- name: Commit and push
if: ${{ steps.git-status-output.outputs.msg != '0' }}
run: |
git config user.email $(echo "${{ steps.last-commit-author.outputs.msg }}" | sed 's/\(.\+\) <\(\S\+\)>/\2/')
git config user.name $(echo "${{ steps.last-commit-author.outputs.msg }}" | sed 's/\(.\+\) <\(\S\+\)>/\1/')
git add AUTHORS.txt
git commit --amend --no-edit
git push --force https://github.com/${GITHUB_REPOSITORY} $(git symbolic-ref -q --short HEAD)
generate:
uses: pion/.goassets/.github/workflows/generate-authors.reusable.yml@master
with:
token: ${{ secrets.PIONBOT_PRIVATE_KEY }}
47 changes: 2 additions & 45 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,50 +12,7 @@
name: Lint
on:
pull_request:
types:
- opened
- edited
- synchronize

permissions:
contents: read

jobs:
lint-commit-message:
name: Metadata
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Commit Message
run: .github/lint-commit-message.sh

- name: File names
run: .github/lint-filename.sh

- name: Functions
run: .github/lint-disallowed-functions-in-library.sh

- name: Logging messages should not have trailing newlines
run: .github/lint-no-trailing-newline-in-log-messages.sh

lint-go:
name: Go
permissions:
contents: read
pull-requests: read
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v3

- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.45.2
args: $GOLANGCI_LINT_EXRA_ARGS
lint:
uses: pion/.goassets/.github/workflows/lint.reusable.yml@master
33 changes: 15 additions & 18 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
name: release
#
# DO NOT EDIT THIS FILE
#
# It is automatically copied from https://github.com/pion/.goassets repository.
# If this repository should have package specific CI config,
# remove the repository name from .goassets/.github/workflows/assets-sync.yml.
#
# If you want to update the shared CI config, send a PR to
# https://github.com/pion/.goassets instead of this repository.
#

name: Release
on:
push:
tags:
- 'v*'

jobs:
release:
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-go@v3
with:
go-version: '1.18' # auto-update/latest-go-version
- name: Build and release
uses: goreleaser/goreleaser-action@v4
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: pion/.goassets/.github/workflows/release.reusable.yml@master
with:
go-version: '1.19' # auto-update/latest-go-version
23 changes: 23 additions & 0 deletions .github/workflows/renovate-go-sum-fix.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#
# DO NOT EDIT THIS FILE
#
# It is automatically copied from https://github.com/pion/.goassets repository.
# If this repository should have package specific CI config,
# remove the repository name from .goassets/.github/workflows/assets-sync.yml.
#
# If you want to update the shared CI config, send a PR to
# https://github.com/pion/.goassets instead of this repository.
#

name: Fix go.sum
on:
push:
branches:
- renovate/*

jobs:
fix:
runs-on: ubuntu-latest
uses: pion/.goassets/.github/workflows/renovate-go-sum-fix.reusable.yml@master
with:
token: ${{ secrets.PIONBOT_PRIVATE_KEY }}
Loading

0 comments on commit 6d600d2

Please sign in to comment.