Skip to content

Commit

Permalink
Revamp Github CI/CD and Integration Testing (#446)
Browse files Browse the repository at this point in the history
Summary:
Make a variety of updates to simplify maintenance of our codebase after the fbcode migration:

* Remove redundant Golang hooks  - we have  `go vet`, `golangci-lint` etc provided internally
* Move non-Python, non-shell linters and checks out of the pre-commit hook.
* Remove mage - we no longer need it now that dependency load has been reduced and integration tests have been simplified
* Remove containers - we delegate containerization to `act`

The payoffs of this refactor are:

* **Much lower maintenance overhead**
  - dependabot's builtin security features can handle security updates for our actions ([source](https://docs.github.com/en/code-security/dependabot/dependabot-security-updates/about-dependabot-security-updates)) so we no longer need renovate to make PRs. We'll only update when we need to.
  - `act` takes care of any required containerization
* Streamlined developer onboarding - just install Golang, only install other tools if needed.
* Faster CI/CD runs - many actions that previously ran in serial now run in parallel
* Improved consistency - we used to have many different Golang versions scattered around the project. They can now be unified in a single action.

Pull Request resolved: #446

Reviewed By: cedowens

Differential Revision: D51518892

Pulled By: d3sch41n

fbshipit-source-id: ea5310743c14e5e450e5d63ef0a09ee8ddad32e5
  • Loading branch information
d3sch41n authored and facebook-github-bot committed Nov 22, 2023
1 parent f8e6ffc commit b79573f
Show file tree
Hide file tree
Showing 36 changed files with 125 additions and 2,118 deletions.
37 changes: 0 additions & 37 deletions .asdf

This file was deleted.

96 changes: 0 additions & 96 deletions .devcontainer/bash/Dockerfile

This file was deleted.

16 changes: 0 additions & 16 deletions .devcontainer/bash/devcontainer.json

This file was deleted.

41 changes: 0 additions & 41 deletions .devcontainer/bash/files/mage_completion.sh

This file was deleted.

1 change: 0 additions & 1 deletion .docgenignore

This file was deleted.

10 changes: 0 additions & 10 deletions .editorconfig

This file was deleted.

7 changes: 0 additions & 7 deletions .github/labels.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,6 @@
color: "#c5def5"
description: >-
Changes made to ttps
# Renovate
- name: renovate/container
color: "ffc300"
- name: renovate/github-action
color: "ffc300"
- name: renovate/github-release
color: "ffc300"
# Semantic Type
- name: type/digest
color: "FFEC19"
Expand Down
47 changes: 0 additions & 47 deletions .github/workflows/container.yaml

This file was deleted.

30 changes: 30 additions & 0 deletions .github/workflows/licenses.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
name: go-licenses
on:
pull_request:
types:
- opened
- synchronize
jobs:
licenses:
name: run go-licenses against this project's dependencies
runs-on: ubuntu-latest
steps:
- name: Checkout Git repository
uses: actions/checkout@v4
- name: Setup Build Environment
uses: actions/setup-go@v4
with:
go-version: "1.21"
- name: Install go-licenses
run: go install github.com/google/go-licenses@latest
- name: Run go-licenses
run: |
output=$(go-licenses check ./... 2> /dev/null)
if [[ "${output}" == *"ERROR: forbidden license found"* ]]; then
echo "Forbidden licenses found. Please remove them."
exit 1
else
echo "No forbidden licenses found."
fi
shell: bash
18 changes: 18 additions & 0 deletions .github/workflows/markdownlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
name: markdownlint
on:
pull_request:
types:
- opened
- synchronize
jobs:
markdownlint:
name: run markdownlint against this codebase
runs-on: ubuntu-latest
steps:
- name: Checkout Git repository
uses: actions/checkout@v4
- name: Run markdownlint
uses: DavidAnson/markdownlint-cli2-action@v13
with:
globs: '**/*.md'
43 changes: 3 additions & 40 deletions .github/workflows/pre-commit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,51 +5,14 @@ on:
types:
- opened
- synchronize
# Run once a week (see https://crontab.guru)
schedule:
- cron: "0 0 * * 0"
workflow_dispatch:
jobs:
pre-commit:
name: Update pre-commit hooks and run pre-commit
runs-on: ubuntu-latest
steps:
- name: Set up git repository
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0

- name: Set up Python
uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 # v4
with:
python-version: "3.x"

- name: Set up Go
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4
with:
go-version: "1.21.0"

- name: Install go module dependencies
run: |
go install mvdan.cc/sh/v3/cmd/shfmt@latest
go install github.com/magefile/mage@latest
- name: Checkout Git repository
uses: actions/checkout@v4
- name: Install pre-commit
run: pip3 install pre-commit

- name: Run go mod tidy - necessary to avoid errors with renovatebot PRs
run: |
go mod tidy
pushd magefiles; go mod tidy; popd
- name: Commit go.mod and go.sum changes to keep pre-commit happy
run: |
git config --global user.email "[email protected]"
git config --global user.name "GitHub Action"
git add go.mod go.sum magefiles/go.mod magefiles/go.sum
git diff --quiet && git diff --staged --quiet || \
git commit -m "Update go.mod and go.sum"
- name: Install pre-commit dependencies
run: mage installDeps

- name: Run pre-commit
run: mage runPreCommit
run: pre-commit run --all-files
Loading

0 comments on commit b79573f

Please sign in to comment.