-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cc16cc0
commit f687f01
Showing
7 changed files
with
275 additions
and
87 deletions.
There are no files selected for viewing
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,149 @@ | ||
name: go-queue_pull_request | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
paths: | ||
- "./" | ||
- ".github/workflows/go-queue_pull_request.yml" | ||
|
||
env: | ||
LINTER_VERSION: "v1.51.2" | ||
GO_VERSION: "1.19" | ||
|
||
jobs: | ||
environment: | ||
runs-on: ubuntu-latest | ||
env: | ||
GITHUB_SHA: ${{ github.event.pull_request.head.sha }} | ||
GITHUB_HEAD_REF: ${{ github.head_ref }} | ||
GITHUB_BASE_REF: ${{ github.base_ref }} | ||
steps: | ||
- name: Get git target | ||
run: | | ||
git_target=`echo $GITHUB_BASE_REF | sed 's/refs\/heads\///'` | ||
git_target=`echo $git_target | sed 's/refs\/tags\///'` | ||
git_target=`echo $git_target| sed 's/refs\\///'` | ||
echo $git_target | ||
echo "git_target=$git_target" >> $GITHUB_ENV | ||
- name: Get git source | ||
run: | | ||
git_source=`echo $GITHUB_HEAD_REF | sed 's/refs\/heads\///'` | ||
git_source=`echo $git_source | sed 's/refs\/tags\///'` | ||
git_source=`echo $git_source | sed 's/refs\\///'` | ||
echo $git_source | ||
echo "git_source=$git_source" >> $GITHUB_ENV | ||
- name: Get git SHA | ||
run: | | ||
git_sha=`echo $GITHUB_SHA` | ||
echo $git_sha | ||
echo "git_sha=$git_sha" >> $GITHUB_ENV | ||
- name: Checkout repository code (source) | ||
uses: actions/checkout@v3 | ||
- name: Get source version | ||
run: | | ||
version_source=`cat /home/runner/work/go-queue/go-queue/version.json | jq '.Version' | sed 's/"//g'` | ||
echo $version_source | ||
echo "version_source=$version_source" >> $GITHUB_ENV | ||
- name: Checkout repository code (target) | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ github.base_ref }} | ||
- name: Get target version | ||
run: | | ||
version_target=`cat /home/runner/work/go-queue/go-queue/version.json | jq '.Version' | sed 's/"//g'` | ||
echo $version_target | ||
echo "version_target=$version_target" >> $GITHUB_ENV | ||
- name: Generate build artifacts | ||
run: | | ||
mkdir -p /tmp | ||
echo ${{ env.version_source }} >> /tmp/version_source | ||
echo ${{ env.version_target }} >> /tmp/version_target | ||
echo ${{ env.git_target }} >> /tmp/git_target | ||
echo ${{ env.git_source }} >> /tmp/git_source | ||
echo ${{ env.git_sha }} >> /tmp/git_sha | ||
- name: Upload artifacts | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: artifacts | ||
path: | | ||
/tmp/version_source | ||
/tmp/version_target | ||
/tmp/git_target | ||
/tmp/git_source | ||
/tmp/git_sha | ||
go_lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/setup-go@v3 | ||
with: | ||
go-version: ${{ env.GO_VERSION }} | ||
- uses: actions/checkout@v3 | ||
- name: golangci-lint | ||
uses: golangci/golangci-lint-action@v3 | ||
with: | ||
version: ${{ env.LINTER_VERSION }} | ||
working-directory: . | ||
args: --verbose | ||
|
||
version_validate: | ||
needs: [environment] | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
steps: | ||
- name: Download artifacts | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: artifacts | ||
path: /tmp | ||
- name: Get environment | ||
run: | | ||
version_source=`cat /tmp/version_source` | ||
echo "version_source=$version_source" >> $GITHUB_ENV | ||
version_target=`cat /tmp/version_target` | ||
echo "version_target=$version_target" >> $GITHUB_ENV | ||
- name: Compare versions | ||
run: | | ||
echo "Comparing version \"${{ env.version_source }}\" to target version \"${{ env.version_target }}\"" | ||
if [ "${{ env.version_source }}" = "${{ env.version_target }}" ]; then | ||
echo "versions are the same, versions must be different" | ||
exit 1 | ||
fi | ||
go_test: | ||
needs: [go_lint, version_validate] | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
steps: | ||
- name: Check out repository code | ||
uses: actions/checkout@v3 | ||
- name: Setup Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: ${{ env.GO_VERSION }} | ||
- name: Test go-queue/finite | ||
continue-on-error: true | ||
run: | | ||
cd /home/runner/work/go-queue/go-queue/finite | ||
go mod download | ||
go test -v ./... -coverprofile /tmp/go-queue-finite.out > /tmp/go-queue-finite.log | ||
- name: Test go-queue/infinite | ||
continue-on-error: true | ||
run: | | ||
cd /home/runner/work/go-queue/go-queue/infinite | ||
go mod download | ||
go test -v ./... -coverprofile /tmp/go-queue-infinite.out > /tmp/go-queue-infinite.log | ||
- name: Upload artifacts | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: artifacts | ||
path: | | ||
/tmp/go-queue-finite.log | ||
/tmp/go-queue-infinite.log | ||
/tmp/go-queue-finite.out | ||
/tmp/go-queue-infinite.out | ||
retention-days: 1 |
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
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
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
Oops, something went wrong.