Skip to content
Open
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
135 changes: 69 additions & 66 deletions .github/workflows/go.yml → .github/workflows/validate.yml
Original file line number Diff line number Diff line change
@@ -1,68 +1,71 @@
---
name: Go
on:
pull_request:
push:
branches:
- main
- "release-*"

# Modified to avoid canceling all matrix jobs when one fails
# Each job type will have its own concurrency group
concurrency:
group: ${{ github.workflow }}-${{ github.job }}-${{ (github.event.pull_request && github.event.pull_request.number) || github.ref || github.run_id }}
cancel-in-progress: true

# Minimal permissions to be inherited by any job that don't declare it's own permissions
permissions:
contents: read

jobs:
supportedVersions:
name: Fetch supported Go versions
runs-on: ubuntu-latest
outputs:
supported_versions: ${{ steps.matrix.outputs.supported_versions }}
steps:
- name: Checkout code
---
name: Validate
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we keep Go name (also in file)? Otherwise we need to change GH CI required checks and generally change the experience of contributing to client_golang. Is it worth the name change?

on:
pull_request:
push:
branches:
- main
- "release-*"

# Modified to avoid canceling all matrix jobs when one fails
# Each job type will have its own concurrency group
concurrency:
group: ${{ github.workflow }}-${{ github.job }}-${{ (github.event.pull_request && github.event.pull_request.number) || github.ref || github.run_id }}
cancel-in-progress: true

# Minimal permissions to be inherited by any job that don't declare it's own permissions
permissions:
contents: read

jobs:
supported_versions:
name: Fetch supported Go versions
runs-on: ubuntu-latest
outputs:
supported_versions: ${{ steps.matrix.outputs.supported_versions }}
steps:
- name: Checkout code
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Read supported_go_versions.txt
id: matrix
run: |
versions=$(cat supported_go_versions.txt)
matrix="[$(echo "$versions" | sed 's/\(.*\)/"\1"/' | paste -s -d,)]"
echo "supported_versions=$matrix" >> $GITHUB_OUTPUT
test:
name: Tests (${{ matrix.go_version }})
runs-on: ubuntu-latest
needs: supportedVersions
# Set fail-fast to false to ensure all Go versions are tested regardless of failures
strategy:
fail-fast: false
matrix:
go_version: ${{ fromJSON(needs.supportedVersions.outputs.supported_versions) }}
# Define concurrency at the job level for matrix jobs
concurrency:
group: ${{ github.workflow }}-test-${{ matrix.go_version }}-${{ (github.event.pull_request && github.event.pull_request.number) || github.ref || github.run_id }}
cancel-in-progress: true

steps:
- name: Checkout code
- name: Read supported_go_versions.txt
id: matrix
run: |
versions=$(cat supported_go_versions.txt)
matrix="[$(echo "$versions" | sed 's/\(.*\)/"\1"/' | paste -s -d,)]"
echo "supported_versions=$matrix" >> $GITHUB_OUTPUT
test:
name: Tests (${{ matrix.go_version }})
runs-on: ubuntu-latest
needs: supportedVersions
# Set fail-fast to false to ensure all Go versions are tested regardless of failures
strategy:
fail-fast: false
matrix:
go_version: ${{ fromJSON(needs.supportedVersions.outputs.supported_versions) }}
# Define concurrency at the job level for matrix jobs
concurrency:
group: ${{ github.workflow }}-test-${{ matrix.go_version }}-${{ (github.event.pull_request && github.event.pull_request.number) || github.ref || github.run_id }}
cancel-in-progress: true

steps:
- name: Checkout code
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0

- name: Set up Go ${{ matrix.go_version }}
uses: actions/setup-go@v6.0.0
with:
go-version: ${{ matrix.go_version }}
check-latest: true
cache-dependency-path: go.sum

- name: Run tests and check license
run: make check_license test
env:
CI: true

- name: Run style and unused
if: ${{ matrix.go_version == '1.22' }}
run: make style unused

- name: Check for CRLF line endings
run: make check-crlf

- name: Set up Go ${{ matrix.go_version }}
uses: actions/setup-go@v6.0.0
with:
go-version: ${{ matrix.go_version }}
check-latest: true
cache-dependency-path: go.sum

- name: Run tests and check license
run: make check_license test
env:
CI: true

- name: Run style and unused
if: ${{ matrix.go_version == '1.22' }}
run: make style unused
20 changes: 20 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,23 @@ test-exp:
.PHONY: test-exp-short
test-exp-short:
cd exp && $(GOTEST) -short $(GOOPTS) $(pkgs)

.PHONY: check-crlf
check-crlf:
@echo ">> checking for CRLF line endings"
@files=$$(find . -type f -not -path "*/\.*" -not -path "*/vendor/*" -exec file {} \; | grep CRLF | cut -d: -f1); \
if [ -n "$$files" ]; then \
echo "Files with CRLF line endings found:"; \
echo "$$files"; \
echo "Run 'make fix-crlf' to fix them"; \
exit 1; \
fi

.PHONY: fix-crlf
fix-crlf:
@echo ">> fixing CRLF line endings"
@files=$$(find . -type f -not -path "*/\.*" -not -path "*/vendor/*" -exec file {} \; | grep CRLF | cut -d: -f1); \
for file in $$files; do \
tr -d '\r' < "$$file" > "$$file.tmp" && mv "$$file.tmp" "$$file"; \
done
@echo ">> CRLF line endings fixed"
Loading