Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/github_actions/actions/cache-4
Browse files Browse the repository at this point in the history
  • Loading branch information
obalunenko committed Feb 20, 2024
2 parents ac5d628 + 426c0ae commit 222e3b5
Show file tree
Hide file tree
Showing 9 changed files with 96 additions and 21 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
matrix:
language: [ 'go' ]
os: [ 'ubuntu-22.04' ]
go: [ '1.21' ]
go-version: [1.22.x]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://git.io/codeql-language-support

Expand All @@ -45,7 +45,7 @@ jobs:
- name: Set up go
uses: actions/setup-go@v5.0.0
with:
go-version: ${{ matrix.go }}
go-version: ${{ matrix.go-version }}
- run: |
go version
shell: bash
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
max-parallel: 3
matrix:
os: [ 'ubuntu-22.04' ]
go: [ '1.21' ]
go-version: [1.22.x]
runs-on: ${{ matrix.os }}
name: Build
steps:
Expand All @@ -53,7 +53,7 @@ jobs:
- name: Set up go
uses: actions/setup-go@v5.0.0
with:
go-version: ${{ matrix.go }}
go-version: ${{ matrix.go-version }}

- run: |
go version
Expand Down Expand Up @@ -88,7 +88,7 @@ jobs:
max-parallel: 2
matrix:
os: [ 'ubuntu-22.04' ]
go: [ '1.21' ]
go-version: [1.22.x]
runs-on: ${{ matrix.os }}
name: Run Tests
steps:
Expand All @@ -100,7 +100,7 @@ jobs:
- name: Set up go
uses: actions/setup-go@v5.0.0
with:
go-version: ${{ matrix.go }}
go-version: ${{ matrix.go-version }}

- run: |
go version
Expand Down Expand Up @@ -135,7 +135,7 @@ jobs:
max-parallel: 2
matrix:
os: [ 'ubuntu-22.04' ]
go: [ '1.21' ]
go-version: [1.22.x]
runs-on: ${{ matrix.os }}
name: Run linters
steps:
Expand All @@ -147,7 +147,7 @@ jobs:
- name: Set up go
uses: actions/setup-go@v5.0.0
with:
go-version: ${{ matrix.go }}
go-version: ${{ matrix.go-version }}
- run: |
go version
shell: bash
Expand Down Expand Up @@ -187,7 +187,7 @@ jobs:
max-parallel: 1
matrix:
os: [ 'ubuntu-22.04' ]
go: [ '1.21' ]
go-version: [1.22.x]
runs-on: ${{ matrix.os }}
name: Quality reports
steps:
Expand All @@ -199,7 +199,7 @@ jobs:
- name: Set up go
uses: actions/setup-go@v5.0.0
with:
go-version: ${{ matrix.go }}
go-version: ${{ matrix.go-version }}
- run: |
go version
shell: bash
Expand Down Expand Up @@ -239,7 +239,7 @@ jobs:
shell: bash

- name: SonarCloud report upload
uses: sonarsource/sonarcloud-github-action@v1.9
uses: sonarsource/sonarcloud-github-action@v2.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ jobs:
max-parallel: 1
matrix:
os: [ 'ubuntu-22.04' ]
go: [ '1.21' ]
go-version: [1.22.x]
runs-on: ${{ matrix.os }}
name: Release
steps:
- name: Set up go
uses: actions/setup-go@v5.0.0
with:
go-version: ${{ matrix.go }}
go-version: ${{ matrix.go-version }}

- name: Checkout
uses: actions/checkout@v4
Expand Down
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ COMPOSE_TOOLS_CMD_BASE=docker compose -f $(COMPOSE_TOOLS_FILE)
COMPOSE_TOOLS_CMD_UP=$(COMPOSE_TOOLS_CMD_BASE) up --exit-code-from
COMPOSE_TOOLS_CMD_PULL=$(COMPOSE_TOOLS_CMD_BASE) pull

GOVERSION:=1.22

TARGET_MAX_CHAR_NUM=20

## Show help
Expand Down Expand Up @@ -117,6 +119,10 @@ check-releaser:
new-version: vet test-regression
./scripts/release/new-version.sh

bump-go-version:
./scripts/bump-go.sh $(GOVERSION)
.PHONY: bump-go-version


.DEFAULT_GOAL := help

2 changes: 1 addition & 1 deletion build/docker/go-tools/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
FROM ghcr.io/obalunenko/go-tools:v1.3.4 AS builder
FROM ghcr.io/obalunenko/go-tools:v1.4.0 AS builder

CMD ["/bin/sh", "-c", ""]
6 changes: 2 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
module github.com/obalunenko/getenv

go 1.21

toolchain go1.21.0
go 1.22

require (
github.com/stretchr/testify v1.8.4
golang.org/x/exp v0.0.0-20230809150735-7b3493d9a819
golang.org/x/exp v0.0.0-20240213143201-ec583247a57a
)

require (
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
golang.org/x/exp v0.0.0-20230809150735-7b3493d9a819 h1:EDuYyU/MkFXllv9QF9819VlI9a4tzGuCbhG0ExK9o1U=
golang.org/x/exp v0.0.0-20230809150735-7b3493d9a819/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc=
golang.org/x/exp v0.0.0-20240213143201-ec583247a57a h1:HinSgX1tJRX3KsL//Gxynpw5CTOAIPhgL4W8PNiIpVE=
golang.org/x/exp v0.0.0-20240213143201-ec583247a57a/go.mod h1:CxmFvTBINI24O/j8iY7H1xHzx2i4OsyguNBmN/uPtqc=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
Expand Down
71 changes: 71 additions & 0 deletions scripts/bump-go.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!/usr/bin/env bash

readonly CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
readonly ROOT_DIR="$(dirname "$CURRENT_DIR")"
readonly GO_MOD_FILE="${ROOT_DIR}/go.mod"

function main() {
echo "Updating Go version:"

local currentGoVersion="$(extractCurrentVersion)"
echo " - Current: ${currentGoVersion}"
local escapedCurrentGoVersion="$(echo "${currentGoVersion}" | sed 's/\./\\./g')"

local goVersion="${1}"
local escapedGoVersion="$(echo "${goVersion}" | sed 's/\./\\./g')"
echo " - New: ${goVersion}"

# bump mod files in all the modules
for modFile in $(find "${ROOT_DIR}" -name "go.mod" -not -path "${ROOT_DIR}/vendor/*" -not -path "${ROOT_DIR}/.git/*"); do
bumpModFile "${modFile}" "${escapedCurrentGoVersion}" "${escapedGoVersion}"
done

# bump markdown files
for f in $(find "${ROOT_DIR}" -name "*.md"); do
bumpGolangDockerImages "${f}" "${escapedCurrentGoVersion}" "${escapedGoVersion}"
done

# bump github action workflows
for f in $(find "${ROOT_DIR}/.github/workflows" -name "*.yml"); do
bumpCIMatrix "${f}" "${escapedCurrentGoVersion}" "${escapedGoVersion}"
done
}

# it will replace the 'go-version: [${oldGoVersion}, 1.x]' with 'go-version: [${newGoVersion}, 1.x]' in the given file
function bumpCIMatrix() {
local file="${1}"
local oldGoVersion="${2}"
local newGoVersion="${3}"

sed "s/go-version: \[${oldGoVersion}/go-version: \[${newGoVersion}/g" ${file} > ${file}.tmp
mv ${file}.tmp ${file}
}

# it will replace the 'golang:${oldGoVersion}' with 'golang:${newGoVersion}' in the given file
function bumpGolangDockerImages() {
local file="${1}"
local oldGoVersion="${2}"
local newGoVersion="${3}"

sed "s/golang:${oldGoVersion}/golang:${newGoVersion}/g" ${file} > ${file}.tmp
mv ${file}.tmp ${file}

}

# it will replace the 'go ${oldGoVersion}' with 'go ${newGoVersion}' in the given go.mod file
function bumpModFile() {
local goModFile="${1}"
local oldGoVersion="${2}"
local newGoVersion="${3}"

sed "s/^go ${oldGoVersion}/go ${newGoVersion}/g" ${goModFile} > ${goModFile}.tmp
mv ${goModFile}.tmp ${goModFile}

}

# This function reads the reaper.go file and extracts the current version.
function extractCurrentVersion() {
cat "${GO_MOD_FILE}" | grep '^go .*' | sed 's/^go //g' | head -n 1
}

main "$@"
2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ github.com/pmezard/go-difflib/difflib
## explicit; go 1.20
github.com/stretchr/testify/assert
github.com/stretchr/testify/require
# golang.org/x/exp v0.0.0-20230809150735-7b3493d9a819
# golang.org/x/exp v0.0.0-20240213143201-ec583247a57a
## explicit; go 1.20
golang.org/x/exp/constraints
# gopkg.in/yaml.v3 v3.0.1
Expand Down

0 comments on commit 222e3b5

Please sign in to comment.