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

fix(latest_version): double check new releases #351

Merged
merged 2 commits into from
Jan 17, 2024
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
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

### [0.15.2](https://github.com/release-argus/Argus/compare/0.15.1...0.15.2) (2024-01-17)


### Bug Fixes

* **latest_version:** double check new releases ([5610a28](https://github.com/release-argus/Argus/commits/5610a28d6982f3033e041903a3ded75585ac4e74))

### [0.15.1](https://github.com/release-argus/Argus/compare/0.15.0...0.15.1) (2024-01-13)


Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "commit-check",
"version": "0.15.1",
"version": "0.15.2",
"description": "",
"main": "index.js",
"scripts": {
Expand Down
22 changes: 18 additions & 4 deletions service/latest_version/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"io"
"net/http"
"strings"
"time"

"github.com/Masterminds/semver/v3"
github_types "github.com/release-argus/Argus/service/latest_version/api_type"
Expand All @@ -31,7 +32,9 @@ import (
// Query queries the Service source, updating Service.LatestVersion
// and returning true if it has changed (is a new release),
// otherwise returns false.
func (l *Lookup) query(logFrom *util.LogFrom) (bool, error) {
//
// checkNumber - 0 for first check, 1 for second check (if the first check found a new version)
func (l *Lookup) query(logFrom *util.LogFrom, checkNumber int) (bool, error) {
rawBody, err := l.httpRequest(logFrom)
if err != nil {
return false, err
Expand All @@ -48,8 +51,16 @@ func (l *Lookup) query(logFrom *util.LogFrom) (bool, error) {
// If this version is different (new?).
latestVersion := l.Status.LatestVersion()
if version != latestVersion {
// Verify that the version has changed. (GitHub may have just omitted the tag for some reason)
if checkNumber == 0 {
msg := fmt.Sprintf("Possibly found a new version (From %q to %q). Checking again", latestVersion, version)
jLog.Verbose(msg, *logFrom, latestVersion != "")
time.Sleep(time.Second)
return l.query(logFrom, 1)
}

if wantSemanticVersioning {
// Check it's a valid semnatic version
// Check it's a valid semantic version
newVersion, err := semver.NewVersion(version)
if err != nil {
err = fmt.Errorf("failed converting %q to a semantic version. If all versions are in this style, consider adding url_commands to get the version into the style of 'MAJOR.MINOR.PATCH' (https://semver.org/), or disabling semantic versioning (globally with defaults.service.semantic_versioning or just for this service with the semantic_versioning var)",
Expand Down Expand Up @@ -103,6 +114,8 @@ func (l *Lookup) query(logFrom *util.LogFrom) (bool, error) {
return true, nil
}

msg := fmt.Sprintf("Staying on %q as that's the latest version in the second check", version)
jLog.Verbose(msg, *logFrom, checkNumber == 1)
// Announce `LastQueried`
l.Status.AnnounceQuery()
// No version change.
Expand All @@ -114,7 +127,7 @@ func (l *Lookup) query(logFrom *util.LogFrom) (bool, error) {
//
// metrics - if true, set Prometheus metrics based on the query
func (l *Lookup) Query(metrics bool, logFrom *util.LogFrom) (newVersion bool, err error) {
newVersion, err = l.query(logFrom)
newVersion, err = l.query(logFrom, 0)

if metrics {
l.queryMetrics(err)
Expand Down Expand Up @@ -228,7 +241,8 @@ func (l *Lookup) httpRequest(logFrom *util.LogFrom) (rawBody []byte, err error)
}
// Has tags/releases
} else {
jLog.Verbose("Potentially found new releases (new ETag)", *logFrom, true)
msg := fmt.Sprintf("Potentially found new releases (new ETag %s)", newETag)
jLog.Verbose(msg, *logFrom, true)
}

// 304 - Resource has not changed
Expand Down
4 changes: 2 additions & 2 deletions service/latest_version/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,12 +359,12 @@ func TestLookup_QueryGitHubETag(t *testing.T) {
"three requests only uses 1 api limit": {
attempts: 3,
eTagChanged: 1,
eTagUnchangedUseCache: 2,
eTagUnchangedUseCache: 3, // 2 attempts + 1 recheck
errRegex: `^$`},
"if initial request fails filter, cached results will be used": {
attempts: 3,
eTagChanged: 1,
eTagUnchangedUseCache: 2,
eTagUnchangedUseCache: 3, // 2 attempts + 1 recheck
initialRequireRegexVersion: `^FOO$`,
errRegex: `regex not matched on version`},
"invalid url_commands will catch no versions": {
Expand Down
2 changes: 1 addition & 1 deletion service/track_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func TestSlice_Track(t *testing.T) {
slice.Track(&tc.ordering, &sync.RWMutex{})

// THEN the function exits straight away
time.Sleep(time.Second)
time.Sleep(2 * time.Second)
for i := range *slice {
if !util.Contains(tc.ordering, i) {
if (*slice)[i].Status.LatestVersion() != "" {
Expand Down
8 changes: 4 additions & 4 deletions web/ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion web/ui/react-app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "argus",
"version": "0.15.1",
"version": "0.15.2",
"description": "Automated checks for new software releases",
"homepage": "https://release-argus.io",
"private": true,
Expand Down
Loading