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

Add debug info for check os version id during manifest findMatch #1112

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
82 changes: 82 additions & 0 deletions packages/tool-cache/__tests__/manifest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import osm = require('os')
// eslint-disable-next-line @typescript-eslint/no-require-imports
import cp = require('child_process')
//import {coerce} from 'semver'
// eslint-disable-next-line @typescript-eslint/no-require-imports
import core = require('@actions/core')

// we fetch the manifest file from main of a repo
const owner = 'actions'
Expand Down Expand Up @@ -245,6 +247,64 @@ describe('@actions/tool-cache-manifest', () => {
expect(release).toBeUndefined()
})

it('does not match ubuntu 18.04 platform version spec on Debain 10', async () => {
os.platform = 'linux'
os.arch = 'x64'

const manifest: mm.IToolRelease[] | null = await tc.getManifestFromRepo(
owner,
repo,
fakeToken
)

readLsbSpy.mockImplementation(() => {
return `NAME="Ubuntu"
VERSION="18.04.5 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.5 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic`
})

const releaseUbuntu:
| tc.IToolRelease
| undefined = await tc.findFromManifest('1.2.4', true, manifest)
expect(releaseUbuntu).toBeDefined()

readLsbSpy.mockImplementation(() => {
return `PRETTY_NAME="Debian GNU/Linux 10 (buster)"
NAME="Debian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"`
})

const debugOutput: string[] = []
const coreSpy = jest.spyOn(core, 'debug')
// it will be cleared in afterEach
coreSpy.mockImplementation(message => debugOutput.push(message))

const releaseDebian:
| tc.IToolRelease
| undefined = await tc.findFromManifest('1.2.4', true, manifest)
expect(releaseDebian).toBeUndefined()
expect(
debugOutput.indexOf(
'OS version: "10" does not match the version python binary is built for: "18.04"'
)
).toBeGreaterThan(-1)
})

it('does not match with unmatched darwin platform version spec', async () => {
os.platform = 'darwin'
os.arch = 'x64'
Expand Down Expand Up @@ -299,6 +359,28 @@ describe('@actions/tool-cache-manifest', () => {
expect(version).toBe('16.04')
})

it('should get version from lsb on debian 10', async () => {
os.platform = 'linux'
os.arch = 'x64'

readLsbSpy.mockImplementation(() => {
return `PRETTY_NAME="Debian GNU/Linux 10 (buster)"
NAME="Debian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"`
})

const version = mm._getOsVersion()

expect(osm.platform()).toBe('linux')
expect(version).toBe('10')
})

// sw_vers -productVersion
it('can get version on macOS', async () => {
os.platform = 'darwin'
Expand Down
5 changes: 5 additions & 0 deletions packages/tool-cache/src/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ export async function _findMatch(
chk = true
} else {
chk = semver.satisfies(osVersion, item.platform_version)
if (!chk) {
debug(
`OS version: "${osVersion}" does not match the version python binary is built for: "${item.platform_version}"`
)
}
}
}

Expand Down