forked from donovanhide/eventsource
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This change replaces CircleCI in favor of GHA, and also drops support for versions of Go (< 1.8) that didn't copy headers when following redirects. I've also added support for testing a minimum Go version in CI, along with associated documentation updates.
- Loading branch information
Showing
24 changed files
with
339 additions
and
137 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
name: Get Go Version | ||
description: "Gets the currently installed Go version." | ||
outputs: | ||
version: | ||
description: 'The currently installed Go version.' | ||
value: ${{ steps.go-version.outputs.value }} | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Get Go version | ||
id: go-version | ||
shell: bash | ||
run: | | ||
echo "value=$(go version | awk '{print $3}')" >> $GITHUB_OUTPUT |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: Unit Tests | ||
description: "Runs unit tests + linters and optionally gathers coverage." | ||
inputs: | ||
lint: | ||
description: 'Whether to run linters.' | ||
required: false | ||
default: 'false' | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- uses: ./.github/actions/get-go-version | ||
id: go-version | ||
- name: Lint | ||
if: inputs.lint == 'true' | ||
shell: bash | ||
run: make lint | ||
|
||
- name: Test | ||
shell: bash | ||
id: test | ||
run: make test | tee raw_report.txt | ||
|
||
- name: Process test results | ||
if: steps.test.outcome == 'success' | ||
id: process-test | ||
shell: bash | ||
run: go run github.com/jstemmer/[email protected] < raw_report.txt > junit_report.xml | ||
|
||
- name: Upload test results | ||
if: steps.process-test.outcome == 'success' | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: Test-result-${{ steps.go-version.outputs.version }} | ||
path: junit_report.xml |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
latest=1.22 | ||
penultimate=1.21 | ||
min=1.17 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
name: Check Supported Go Versions | ||
on: | ||
schedule: | ||
- cron: "0 17 * * *" | ||
workflow_dispatch: | ||
|
||
jobs: | ||
check-go-eol: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
latest: ${{ steps.parse.outputs.latest }} | ||
penultimate: ${{ steps.parse.outputs.penultimate }} | ||
timeout-minutes: 2 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
# Perform a GET request to endoflife.date for the Go language. The response | ||
# contains all Go releases; we're interested in the 0'th and 1'th (latest and penultimate.) | ||
- name: Fetch officially supported Go versions | ||
uses: JamesIves/fetch-api-data-action@396ebea7d13904824f85b892b1616985f847301c | ||
with: | ||
endpoint: https://endoflife.date/api/go.json | ||
configuration: '{ "method": "GET" }' | ||
debug: true | ||
# Parse the response JSON and insert into environment variables for the next step. | ||
- name: Parse officially supported Go versions | ||
id: parse | ||
run: | | ||
echo "latest=${{ fromJSON(env.fetch-api-data)[0].cycle }}" >> $GITHUB_OUTPUT | ||
echo "penultimate=${{ fromJSON(env.fetch-api-data)[1].cycle }}" >> $GITHUB_OUTPUT | ||
create-prs: | ||
permissions: | ||
contents: write | ||
pull-requests: write | ||
needs: check-go-eol | ||
runs-on: ubuntu-latest | ||
env: | ||
officialLatestVersion: ${{ needs.check-go-eol.outputs.latest }} | ||
officialPenultimateVersion: ${{ needs.check-go-eol.outputs.penultimate }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Get current Go versions | ||
id: go-versions | ||
run: cat ./.github/variables/go-versions.env > $GITHUB_OUTPUT | ||
|
||
- name: Update go-versions.env and README.md | ||
if: steps.go-versions.outputs.latest != env.officialLatestVersion | ||
id: update-go-versions | ||
run: | | ||
sed -i -e "s#latest=[^ ]*#latest=${{ env.officialLatestVersion }}#g" \ | ||
-e "s#penultimate=[^ ]*#penultimate=${{ env.officialPenultimateVersion }}#g" \ | ||
./.github/variables/go-versions.env | ||
sed -i "s/Go version ${{ steps.go-versions.outputs.penultimate }}/Go version ${{ env.officialPenultimateVersion }}/g" \ | ||
README.md | ||
- name: Create pull request | ||
if: steps.update-go-mod.outcome == 'success' | ||
uses: peter-evans/create-pull-request@v6 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
add-paths: | | ||
.github/variables/go-versions.env | ||
README.md | ||
branch: "launchdarklyreleasebot/update-to-go${{ env.officialLatestVersion }}-${{ matrix.branch }}" | ||
author: "LaunchDarklyReleaseBot <[email protected]>" | ||
committer: "LaunchDarklyReleaseBot <[email protected]>" | ||
labels: ${{ matrix.branch }} | ||
title: "fix(deps): bump supported Go versions to ${{ env.officialLatestVersion }} and ${{ env.officialPenultimateVersion }}" | ||
commit-message: "Bumps from Go ${{ steps.go-versions.outputs.latest }} -> ${{ env.officialLatestVersion }} and ${{ steps.go-versions.outputs.penultimate }} -> ${{ env.officialPenultimateVersion }}." | ||
body: | | ||
- [ ] I have triggered CI on this PR (either close & reopen this PR in Github UI, or `git commit -m "run ci" --allow-empty && git push`) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: Build and Test | ||
on: | ||
push: | ||
branches: [ 'main', 'feat/**' ] | ||
paths-ignore: | ||
- '**.md' # Don't run CI on markdown changes. | ||
pull_request: | ||
branches: [ 'main', 'feat/**' ] | ||
paths-ignore: | ||
- '**.md' | ||
|
||
jobs: | ||
go-versions: | ||
uses: ./.github/workflows/go-versions.yml | ||
|
||
# Runs the common tasks (unit tests, lint, contract tests) for each Go version. | ||
test-linux: | ||
name: ${{ format('Linux, Go {0}', matrix.go-version) }} | ||
needs: go-versions | ||
strategy: | ||
# Let jobs fail independently, in case it's a single version that's broken. | ||
fail-fast: false | ||
matrix: | ||
go-version: ${{ fromJSON(needs.go-versions.outputs.matrix) }} | ||
uses: ./.github/workflows/common_ci.yml | ||
with: | ||
go-version: ${{ matrix.go-version }} | ||
|
||
test-windows: | ||
name: ${{ format('Windows, Go {0}', matrix.go-version) }} | ||
runs-on: windows-2022 | ||
needs: go-versions | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
go-version: ${{ fromJSON(needs.go-versions.outputs.matrix) }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Setup Go ${{ matrix.go-version }} | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: ${{ matrix.go-version }} | ||
- name: Test | ||
run: go test -race ./... |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: Common CI | ||
on: | ||
workflow_call: | ||
inputs: | ||
go-version: | ||
description: "Go version to use for the jobs." | ||
required: true | ||
type: string | ||
|
||
jobs: | ||
unit-tests: | ||
runs-on: ubuntu-latest | ||
name: 'Unit Tests' | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Setup Go ${{ inputs.go-version }} | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: ${{ inputs.go-version }} | ||
- uses: ./.github/actions/unit-tests | ||
with: | ||
lint: 'true' | ||
|
||
contract-tests: | ||
runs-on: ubuntu-latest | ||
name: 'Contract Tests' | ||
env: | ||
TEST_SERVICE_PORT: 8000 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Setup Go ${{ inputs.go-version }} | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: ${{ inputs.go-version }} | ||
- uses: ./.github/actions/get-go-version | ||
id: go-version | ||
- name: Start test service in background | ||
run: make start-contract-test-service-bg | ||
- uses: launchdarkly/gh-actions/actions/[email protected] | ||
continue-on-error: true | ||
with: | ||
test_service_port: ${{ env.TEST_SERVICE_PORT }} | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Upload test service logs | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: Contract-test-service-logs-${{ steps.go-version.outputs.version }} | ||
path: /tmp/sdk-contract-test-service.log |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# The following chunk of yml boils down to pulling two Go version numbers out of a file and | ||
# making them available to the other workflows in a convenient fashion. | ||
# | ||
# It's a reusable workflow instead of an action so that its output can be used in a matrix strategy | ||
# of another job. | ||
# | ||
# The idea is to define the most recent, and penultimate, Go versions that should be used to test Relay. | ||
# Ideally we'd define these in a single place - otherwise we'd need to update many different places in | ||
# each workflow. This single place is .github/variables/go-versions.env. | ||
# | ||
# This reusable workflow grabs them out of the file, then sets them as outputs. As a convenience, it | ||
# also wraps each version in an array, so it can be directly used in a matrix strategy. Single-item matrices | ||
# are nice because you can tell instantly in the Github UI which version is being tested without needing | ||
# to inspect logs. | ||
# | ||
# To use a matrix output, e.g. latest version, do: | ||
# strategy: | ||
# matrix: ${{ fromJSON(this-job.outputs.latest-matrix) }} | ||
# | ||
name: Go Versions | ||
on: | ||
workflow_call: | ||
outputs: | ||
latest: | ||
description: 'The most recent Go version to test' | ||
value: ${{ jobs.go-versions.outputs.latest }} | ||
penultimate: | ||
description: 'The second most recent Go version to test' | ||
value: ${{ jobs.go-versions.outputs.penultimate }} | ||
min: | ||
description: 'The minimum Go version to test' | ||
value: ${{ jobs.go-versions.outputs.min }} | ||
matrix: | ||
description: 'All Go versions to test as a matrix' | ||
value: ${{ jobs.go-versions.outputs.all }} | ||
|
||
jobs: | ||
go-versions: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
latest: ${{ steps.set-env.outputs.latest }} | ||
penultimate: ${{ steps.set-env.outputs.penultimate }} | ||
all: ${{ steps.set-matrix.outputs.all }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set Go Versions | ||
id: set-env | ||
run: cat ./.github/variables/go-versions.env > $GITHUB_OUTPUT | ||
- name: Set Go Version Matrices | ||
id: set-matrix | ||
run: | | ||
echo "all=[\"${{ steps.set-env.outputs.latest }}\",\"${{ steps.set-env.outputs.penultimate }}\",\"${{ steps.set-env.outputs.min }}\"]" >> $GITHUB_OUTPUT |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
name: 'Close stale issues and PRs' | ||
on: | ||
workflow_dispatch: | ||
schedule: | ||
# Happen once per day at 1:30 AM | ||
- cron: '30 1 * * *' | ||
|
||
jobs: | ||
sdk-close-stale: | ||
uses: launchdarkly/gh-actions/.github/workflows/sdk-stale.yml@main |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
bin/ | ||
.vscode/ | ||
.idea |
Oops, something went wrong.