diff --git a/.github/workflows/windows-validation.yml b/.github/workflows/windows-validation.yml index b764d0c..8c87720 100644 --- a/.github/workflows/windows-validation.yml +++ b/.github/workflows/windows-validation.yml @@ -11,48 +11,24 @@ on: - '**.md' jobs: - create-link-on-windows: + create-link-if-not-default: runs-on: windows-latest + name: 'Setup ${{ matrix.go }}, cache: ${{ matrix.cache }}' strategy: matrix: cache: [false, true] - go: [1.20.1, 1.20.5] - name: 'Setup ${{ matrix.go }} cache: ${{ matrix.cache }}' + go: [1.20.1] steps: - uses: actions/checkout@v3 - - uses: ./ + - name: non-default-cache-${{ matrix.cache }}-${{ matrix.go }} + uses: ./ with: go-version: ${{ matrix.go }} 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' # make sure drive c: contains only a link size=$(du -m -s 'C:\hostedtoolcache\windows\go\${{ matrix.go }}\x64'|cut -f1 -d$'\t') @@ -61,10 +37,22 @@ jobs: exit 1 fi 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 which go go version @@ -78,4 +66,48 @@ jobs: exit 1 fi 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 diff --git a/__tests__/setup-go.test.ts b/__tests__/setup-go.test.ts index ffe8c2e..70f2166 100644 --- a/__tests__/setup-go.test.ts +++ b/__tests__/setup-go.test.ts @@ -11,12 +11,13 @@ import * as im from '../src/installer'; import goJsonData from './data/golang-dl.json'; import matchers from '../matchers.json'; import goTestManifest from './data/versions-manifest.json'; -import {addExecutablesToCache, IGoVersionInfo} from '../src/installer'; const matcherPattern = matchers.problemMatcher[0].pattern[0]; const matcherRegExp = new RegExp(matcherPattern.regexp); const win32Join = path.win32.join; const posixJoin = path.posix.join; +jest.setTimeout(10000); + describe('setup-go', () => { let inputs = {} as any; let os = {} as any; diff --git a/__tests__/windows-performance.test.ts b/__tests__/windows-performance.test.ts index 451744b..bfb1644 100644 --- a/__tests__/windows-performance.test.ts +++ b/__tests__/windows-performance.test.ts @@ -43,6 +43,9 @@ describe('Windows performance workaround', () => { jest.clearAllMocks(); 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 () => { const info: IGoVersionInfo = { type: 'dist',