Update LICENSE to Apache 2.0 #4837
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Runs pre-commit on changed files only. | |
name: pre-commit | |
on: | |
push: | |
branches: | |
- master | |
- dev | |
- "release/**" | |
pull_request: | |
branches: | |
- master | |
- dev | |
- "release/**" | |
jobs: | |
pre-commit: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Setup Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version: "1.18.0" | |
- uses: actions/checkout@v3 | |
# NOTE: This will fetch the entire git history which is needed for the | |
# `github.event.before`. | |
# TODO: Not sure how slow this is. | |
with: | |
fetch-depth: 0 | |
- name: Set up Python 3.8 | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.8 | |
- name: Get changed files | |
id: getChangedFiles | |
run: | | |
# (1) Whenever we do a PR we want pre-commit to run on all the files that have changed | |
# with respect to the branch we want to merge into. We don't want to compare to the file | |
# changes w.r.t. the last commit on the PR branch. | |
# (2) Whenever `github.event.before` is empty, it means we have hit the edge case where a | |
# branch does not yet contain any commits. This happens whenever a PR is created (GitHub | |
# creates a special PR merge branch) and the branch we want to merge did not have any | |
# commits yet. So this should fall under the `pull_request` case, but wanted to be | |
# explicit in case we want to make changes in the future. | |
# (3) If `github.event.before` is equal to a bunch of zeros, then we have hit another edge | |
# case. Triggered when a first push has been made to a new release branch. For this case | |
# we make use of the fact that we will always merge the release branch into master. | |
if [[ "${{ github.event.before }}" = "" ]] || [[ "${{ github.event_name }}" = "pull_request" ]]; then | |
echo "First deployment of new branch" | |
# Piped into xargs so that all the lines are outputted in a single line (so no newline | |
# characters). | |
CHANGEDFILES="$(git diff --name-only origin/${{ github.event.pull_request.base.ref }} ${{ github.sha }} | xargs)" | |
elif [[ "${{ github.event.before }}" = "0000000000000000000000000000000000000000" ]]; then | |
echo "First push to a new release branch" | |
CHANGEDFILES="$(git diff --name-only HEAD^ HEAD | xargs)" | |
else | |
echo "Not the first deployment" | |
# Piped into xargs so that all the lines are outputted in a single line (so no newline | |
# characters). | |
CHANGEDFILES="$(git diff --name-only ${{ github.event.before }} ${{ github.sha }} | xargs)" | |
fi | |
echo Found changed files: "$CHANGEDFILES" | |
# https://docs.github.com/en/actions/learn-github-actions/workflow-commands-for-github-actions#setting-an-output-parameter | |
echo "::set-output name=changed_files::$CHANGEDFILES" | |
- uses: pre-commit/action@v2.0.0 | |
with: | |
# https://docs.github.com/en/actions/learn-github-actions/contexts#steps-context | |
extra_args: --files ${{ steps.getChangedFiles.outputs.changed_files }} |