Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate Repo to Github Actions #132

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 0 additions & 91 deletions .circleci/config.yml

This file was deleted.

35 changes: 35 additions & 0 deletions .github/actions/publish-junit/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Publish JUnit Tests
description: Publishes JUnit tests to one or more sources
inputs:
files:
required: true
description: The JUnit files to upload
name:
required: true
description: The name of the suite
datadog:
required: false
description: Upload to Datadog
default: 'true'
github:
required: false
description: Upload to GitHub
default: 'true'

runs:
using: composite
steps:
- name: Report Tests to Datadog
shell: bash
if: ${{ inputs.datadog }} == 'true'
run: datadog-ci junit upload --service ${{ inputs.name }} ${{ inputs.files }}

- name: Test Publish
uses: phoenix-actions/test-reporting@f957cd93fc2d848d556fa0d03c57bc79127b6b5e # v15
if: ${{ inputs.github }} == 'true'
with:
name: ${{ inputs.name }}
output-to: step-summary
path: ${{ inputs.files }}
reporter: java-junit
fail-on-error: 'false'
99 changes: 95 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,79 @@
# Run test file with command:
# act pull_request -e testdata/act/pull-request.json

name: Test find flags
name: Test and Generate Docs

on: pull_request

jobs:
find-feature-flags:
go-test:
runs-on: ubuntu-latest
name: Test Find Flags
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29

- name: Set up Node.js
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af
with:
node-version: '18.x'

- name: Install datadog-ci
run: npm install -g @datadog/datadog-ci

- name: Set up Python
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b
with:
python-version: '3.x'

- name: Install pre-commit
run: |
python -m pip install --upgrade pip
pip install pre-commit

- name: Run pre-commit hooks
run: pre-commit run --all-files

- name: Set up Go
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed
with:
go-version-file: go.mod

- name: Install dependencies
run: go mod tidy

- name: Install gotestsum
run: go install gotest.tools/gotestsum@latest

- name: Run tests with gotestsum
run: |
mkdir -p ${{ github.workspace }}/artifacts
mkdir -p ${{ github.workspace }}/reports

GONFALON_MODE=test \
gotestsum --packages="./..." \
--junitfile ${{ github.workspace }}/reports/go-test_go_tests.xml \
--jsonfile ${{ github.workspace }}/artifacts/go-test_go_tests.json \
--rerun-fails=2 \
--rerun-fails-max-failures=10 \
--rerun-fails-report ${{ github.workspace }}/artifacts/rerun_tests_go_tests.txt \
-- -tags=launchdarkly_easyjson -p=1

- name: Publish JUnit Tests
uses: ./.github/actions/publish-junit
env:
DD_API_KEY: ${{ secrets.DATADOG_API_KEY }}
kevinkruger marked this conversation as resolved.
Show resolved Hide resolved
with:
files: ${{ github.workspace }}/reports/go-test_go_tests.xml
name: find-code-references-in-pull-request
datadog: 'true'
github: 'true'


e2e-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29
- name: Find LaunchDarkly feature flags in diff
uses: ./ # Uses an action in the root directory
id: find-flags
Expand Down Expand Up @@ -50,3 +113,31 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.pull_request.number }}

generate-docs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29

- name: Set up Python
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b
with:
python-version: '3.x'

- name: Install pre-commit
run: |
python -m pip install --upgrade pip
pip install pre-commit

- name: Set up Node.js
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af
with:
node-version: '18.8.0'

- name: Install action-docs
run: npm install action-docs

- name: Run pre-commit for GitHub Actions Docs
run: pre-commit run -a github-action-docs

hoshsadiq marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/golangci/golangci-lint
rev: v1.52.2
rev: v1.62.2
hooks:
- id: golangci-lint
name: golangci-lint
Expand Down
5 changes: 4 additions & 1 deletion diff/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@ func ProcessDiffs(matcher lsearch.Matcher, contents []byte, builder *refs.Refere
for _, flagKey := range elementMatcher.FindMatches(line) {
aliasMatches := elementMatcher.FindAliases(line, flagKey)
gha.Debug("Found (%s) reference to flag %s with aliases %v", op, flagKey, aliasMatches)
builder.AddReference(flagKey, op, aliasMatches)
err := builder.AddReference(flagKey, op, aliasMatches)
if err != nil {
fmt.Println(err)
}
}
if builder.MaxReferences() {
break
Expand Down
2 changes: 1 addition & 1 deletion internal/github_actions/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func MaskInput(input string) {
}

func Log(format string, a ...any) {
log.Println(fmt.Sprintf(format, a...))
fmt.Printf(format, a...)
}

func LogError(err error) {
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ func setOutputsForChangedFlags(modifier string, changedFlags []string) {
func failExit(err error) {
if err != nil {
gha.LogError(err)
gha.SetError(err.Error())
gha.SetError("%s", err.Error())
os.Exit(1)
}
}
Loading