mirror of
https://github.com/actions/setup-go.git
synced 2025-04-23 17:40:50 +00:00
improve tests
This commit is contained in:
parent
8998c6804e
commit
42a70ecdee
3 changed files with 72 additions and 36 deletions
102
.github/workflows/windows-validation.yml
vendored
102
.github/workflows/windows-validation.yml
vendored
|
@ -11,48 +11,24 @@ on:
|
||||||
- '**.md'
|
- '**.md'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
create-link-on-windows:
|
create-link-if-not-default:
|
||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
|
name: 'Setup ${{ matrix.go }}, cache: ${{ matrix.cache }}'
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
cache: [false, true]
|
cache: [false, true]
|
||||||
go: [1.20.1, 1.20.5]
|
go: [1.20.1]
|
||||||
name: 'Setup ${{ matrix.go }} cache: ${{ matrix.cache }}'
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- uses: ./
|
- name: non-default-cache-${{ matrix.cache }}-${{ matrix.go }}
|
||||||
|
uses: ./
|
||||||
with:
|
with:
|
||||||
go-version: ${{ matrix.go }}
|
go-version: ${{ matrix.go }}
|
||||||
cache: ${{ matrix.cache }}
|
cache: ${{ matrix.cache }}
|
||||||
name: v4-cache-${{ matrix.cache }}
|
|
||||||
|
|
||||||
- run: |
|
|
||||||
if [ -e 'D:\hostedtoolcache\windows\go\${{ matrix.go }}\x64' ];then
|
|
||||||
echo 'D:\hostedtoolcache\windows\go\${{ matrix.go }}\x64 should not exist for hosted version of go';
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
du -m -s 'C:\hostedtoolcache\windows\go\${{ matrix.go }}\x64'
|
|
||||||
# make sure drive c: contains the folder
|
|
||||||
size=$(du -m -s 'C:\hostedtoolcache\windows\go\${{ matrix.go }}\x64'|cut -f1 -d$'\t')
|
|
||||||
if [ $size -eq 0 ];then
|
|
||||||
echo 'Size of the hosted go installed on drive c: must be above zero'
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
shell: bash
|
|
||||||
name: Hosted go should not have link
|
|
||||||
if: ${{ matrix.go == '1.20.5' }}
|
|
||||||
|
|
||||||
- run: |
|
|
||||||
du -m -s 'D:\hostedtoolcache\windows\go\${{ matrix.go }}\x64'
|
|
||||||
size=$(du -m -s 'D:\hostedtoolcache\windows\go\${{ matrix.go }}\x64'|cut -f1 -d$'\t')
|
|
||||||
# make sure archive does not take lot of space
|
|
||||||
if [ $size -gt 999 ];then
|
|
||||||
echo 'Size of installed on drive d: go is too big';
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
- name: 'Drive C: should have zero size link'
|
||||||
|
run: |
|
||||||
du -m -s 'C:\hostedtoolcache\windows\go\${{ matrix.go }}\x64'
|
du -m -s 'C:\hostedtoolcache\windows\go\${{ matrix.go }}\x64'
|
||||||
# make sure drive c: contains only a link
|
# make sure drive c: contains only a link
|
||||||
size=$(du -m -s 'C:\hostedtoolcache\windows\go\${{ matrix.go }}\x64'|cut -f1 -d$'\t')
|
size=$(du -m -s 'C:\hostedtoolcache\windows\go\${{ matrix.go }}\x64'|cut -f1 -d$'\t')
|
||||||
|
@ -61,10 +37,22 @@ jobs:
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
shell: bash
|
shell: bash
|
||||||
name: Disk usage
|
|
||||||
if: ${{ matrix.go != '1.20.5' }}
|
|
||||||
|
|
||||||
- run: |
|
# Drive D: is small, take care the action does not eat up the space
|
||||||
|
- name: 'Drive D: space usage should be below 1G'
|
||||||
|
run: |
|
||||||
|
du -m -s 'D:\hostedtoolcache\windows\go\${{ matrix.go }}\x64'
|
||||||
|
size=$(du -m -s 'D:\hostedtoolcache\windows\go\${{ matrix.go }}\x64'|cut -f1 -d$'\t')
|
||||||
|
# make sure archive does not take lot of space
|
||||||
|
if [ $size -gt 999 ];then
|
||||||
|
echo 'Size of installed on drive d: go is too big';
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
# make sure the Go installation has not been changed to the end user
|
||||||
|
- name: Test paths and environments
|
||||||
|
run: |
|
||||||
echo $PATH
|
echo $PATH
|
||||||
which go
|
which go
|
||||||
go version
|
go version
|
||||||
|
@ -78,4 +66,48 @@ jobs:
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
shell: bash
|
shell: bash
|
||||||
name: test paths and environments
|
|
||||||
|
find-default-go:
|
||||||
|
name: 'Find default go version'
|
||||||
|
runs-on: windows-latest
|
||||||
|
outputs:
|
||||||
|
version: ${{ steps.goversion.outputs.version }}
|
||||||
|
steps:
|
||||||
|
- run: |
|
||||||
|
version=`go env GOVERSION|sed s/^go//`
|
||||||
|
echo "default go version: $version"
|
||||||
|
echo "version=$version" >> "$GITHUB_OUTPUT"
|
||||||
|
id: goversion
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
dont-create-link-if-default:
|
||||||
|
name: 'Use default go, cache: ${{ matrix.cache }}'
|
||||||
|
runs-on: windows-latest
|
||||||
|
needs: find-default-go
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
cache: [false, true]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- uses: ./
|
||||||
|
with:
|
||||||
|
go-version: ${{ needs.find-default-go.outputs.version }}
|
||||||
|
cache: ${{ matrix.cache }}
|
||||||
|
|
||||||
|
- name: 'Drive C: should have Go installation'
|
||||||
|
run: |
|
||||||
|
size=$(du -m -s 'C:\hostedtoolcache\windows\go\${{ needs.find-default-go.outputs.version }}\x64'|cut -f1 -d$'\t')
|
||||||
|
if [ $size -eq 0 ];then
|
||||||
|
echo 'Size of the hosted go installed on drive c: must be above zero'
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
- name: 'Drive D: should not have Go installation'
|
||||||
|
run: |
|
||||||
|
if [ -e 'D:\hostedtoolcache\windows\go\${{ needs.find-default-go.outputs.version }}\x64' ];then
|
||||||
|
echo 'D:\hostedtoolcache\windows\go\${{ needs.find-default-go.outputs.version }}\x64 should not exist for hosted version of go';
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
shell: bash
|
||||||
|
|
|
@ -11,12 +11,13 @@ import * as im from '../src/installer';
|
||||||
import goJsonData from './data/golang-dl.json';
|
import goJsonData from './data/golang-dl.json';
|
||||||
import matchers from '../matchers.json';
|
import matchers from '../matchers.json';
|
||||||
import goTestManifest from './data/versions-manifest.json';
|
import goTestManifest from './data/versions-manifest.json';
|
||||||
import {addExecutablesToCache, IGoVersionInfo} from '../src/installer';
|
|
||||||
const matcherPattern = matchers.problemMatcher[0].pattern[0];
|
const matcherPattern = matchers.problemMatcher[0].pattern[0];
|
||||||
const matcherRegExp = new RegExp(matcherPattern.regexp);
|
const matcherRegExp = new RegExp(matcherPattern.regexp);
|
||||||
const win32Join = path.win32.join;
|
const win32Join = path.win32.join;
|
||||||
const posixJoin = path.posix.join;
|
const posixJoin = path.posix.join;
|
||||||
|
|
||||||
|
jest.setTimeout(10000);
|
||||||
|
|
||||||
describe('setup-go', () => {
|
describe('setup-go', () => {
|
||||||
let inputs = {} as any;
|
let inputs = {} as any;
|
||||||
let os = {} as any;
|
let os = {} as any;
|
||||||
|
|
|
@ -43,6 +43,9 @@ describe('Windows performance workaround', () => {
|
||||||
jest.clearAllMocks();
|
jest.clearAllMocks();
|
||||||
process.env['RUNNER_TOOL_CACHE'] = runnerToolCache;
|
process.env['RUNNER_TOOL_CACHE'] = runnerToolCache;
|
||||||
});
|
});
|
||||||
|
// addExecutablesToCache uses 3rd party dependency toolkit.cache under the hood
|
||||||
|
// that currently is implemented with RUNNER_TOOL_CACHE environment variable
|
||||||
|
// Make sure the implementation has not been changed
|
||||||
it('addExecutablesToCache should depend on env[RUNNER_TOOL_CACHE]', async () => {
|
it('addExecutablesToCache should depend on env[RUNNER_TOOL_CACHE]', async () => {
|
||||||
const info: IGoVersionInfo = {
|
const info: IGoVersionInfo = {
|
||||||
type: 'dist',
|
type: 'dist',
|
||||||
|
|
Loading…
Add table
Reference in a new issue