diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 5f6c971e7..ff1d367c9 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -1,4 +1,4 @@ -name: golangci-lint +name: Lint Checks on: pull_request: permissions: @@ -23,3 +23,7 @@ jobs: - name: Check go.mod run: | go mod tidy && git diff --exit-code + + - name: Check natives build tags + run: | + diff -u <(echo -n) <(go list ./compiler/natives/src/...) # All those packages should have // +build js. diff --git a/.github/workflows/measure-size.yml b/.github/workflows/measure-size.yml index d193b0df6..1c764cd0c 100644 --- a/.github/workflows/measure-size.yml +++ b/.github/workflows/measure-size.yml @@ -1,28 +1,29 @@ -name: Measure canonical app size +# Temporarily disabling this, to avoid cluttering the PR. I won't merge this commit +# name: Measure canonical app size -on: ['pull_request'] +# on: ['pull_request'] -jobs: - measure: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - uses: actions/setup-go@v2 - with: - go-version: '~1.18.10' - - uses: gopherjs/output-size-action/measure@main - with: - name: jQuery TodoMVC - repo: https://github.com/gopherjs/todomvc - go-package: github.com/gopherjs/todomvc - report_json: /tmp/report.json - report_md: /tmp/report.md - - uses: actions/upload-artifact@v2 - with: - name: size_report - path: | - /tmp/report.json - /tmp/report.md +# jobs: +# measure: +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v2 +# with: +# fetch-depth: 0 +# - uses: actions/setup-go@v2 +# with: +# go-version: '~1.18.10' +# - uses: gopherjs/output-size-action/measure@main +# with: +# name: jQuery TodoMVC +# repo: https://github.com/gopherjs/todomvc +# go-package: github.com/gopherjs/todomvc +# report_json: /tmp/report.json +# report_md: /tmp/report.md +# - uses: actions/upload-artifact@v2 +# with: +# name: size_report +# path: | +# /tmp/report.json +# /tmp/report.md diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 000000000..537923131 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,173 @@ +name: Tests +on: + pull_request: +permissions: + contents: read +jobs: + tests: + name: tests + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + include: + - os: ubuntu-latest + index: 0 + - os: ubuntu-latest + index: 1 + - os: ubuntu-latest + index: 2 + - os: ubuntu-latest + index: 3 + + steps: + - uses: actions/setup-go@v3 + with: + go-version: "1.18.10" + - uses: actions/setup-node@v3 + with: + node-version: "12" + - name: Set up environment + if: matrix.os != 'windows-latest' + run: | + echo "SOURCE_MAP_SUPPORT=true" >> $GITHUB_ENV + # Make nodejs able to require installed modules from any working path. + echo "NODE_PATH=$(npm root)" >> $GITHUB_ENV + echo ::notice::$(go version) + echo ::notice::$(node -v) + echo ::notice::$(npm -v) + - name: Set up environment + if: matrix.os == 'windows-latest' + run: | + # Fix TEMP variable, see https://github.com/actions/runner-images/issues/712#issuecomment-613004302 + echo "TEMP=$env:USERPROFILE\AppData\Local\Temp" >> $env:GITHUB_ENV + echo "TMP=$env:USERPROFILE\AppData\Local\Temp" >> $env:GITHUB_ENV + echo "TMPDIR=$env:USERPROFILE\AppData\Local\Temp" >> $env:GITHUB_ENV + echo "NODE_PATH=$(npm root)" >> $env:GITHUB_ENV + echo "SOURCE_MAP_SUPPORT=false" >> $env:GITHUB_ENV + echo "::notice::$(npm root)" + echo "::notice::$(node -v)" + echo "::notice::$(npm -v)" + - uses: actions/checkout@v3 + - name: Install required Node.js packages + if: matrix.os == 'ubuntu-latest' + run: | + npm ci + - name: Install required Node.js packages + if: matrix.os != 'ubuntu-latest' + run: | + # Extra flags to avoid installing node-syscall. + npm install --no-optional --no-package-lock + - name: Build and Install GopherJS + run: | + go install -v + echo ::notice::$(gopherjs version) + + - name: Smoke tests + if: matrix.os == 'ubuntu-latest' + run: | + gopherjs build -v net/http + gopherjs test -v fmt log + - name: Smoke tests + if: matrix.os == 'macos-latest' + run: | + gopherjs build -v net/http + gopherjs test -v --short fmt log os ./tests + - name: Smoke tests + if: matrix.os == 'windows-latest' + run: | + gopherjs build -v net/http + gopherjs test -v --short fmt sort ./tests + - name: go test ... + if: matrix.os != 'windows-latest' + run: | + # Run all tests except gorepo, which will be run separately in parallel. + go test -v -race $(go list ./... | grep -v github.com/gopherjs/gopherjs/tests/gorepo) + - name: go test ... + if: matrix.os == 'windows-latest' + run: | + $ErrorActionPreference = "Stop" + # Run all tests except gorepo, which will be run separately in parallel. + go test -v -race $(go list ./... | Where-Object { $_ -notmatch "github.com/gopherjs/gopherjs/tests/gorepo" }) + - name: TodoMVC in GOPATH mode + if: matrix.os != 'windows-latest' + run: | + set -e + export GO111MODULE=off + export GOPATH=/tmp/gopath + mkdir -p $GOPATH/src/github.com/gopherjs/gopherjs + cp -r -p . $GOPATH/src/github.com/gopherjs/gopherjs/ + go get -v github.com/gopherjs/todomvc + gopherjs build -v -o /tmp/todomvc_gopath.js github.com/gopherjs/todomvc + gopherjs test -v github.com/gopherjs/todomvc/... + - name: TodoMVC in GOPATH mode + if: matrix.os == 'windows-latest' + run: | + $ErrorActionPreference = "Stop" + $env:GO111MODULE = "off" + $env:GOPATH = "C:\tmp\gopath" + $destinationPath = "$env:GOPATH\src\github.com\gopherjs\gopherjs" + if (-not (Test-Path $destinationPath)) { + New-Item -ItemType Directory -Force -Path $destinationPath + } + Copy-Item -Recurse -Path . -Destination $destinationPath + go get -v github.com/gopherjs/todomvc + gopherjs build -v -o C:\tmp\todomvc_gopath.js github.com/gopherjs/todomvc + gopherjs test -v github.com/gopherjs/todomvc/... + - name: TodoMVC in Modules mode + if: matrix.os != 'windows-latest' + run: | + set -e + cd /tmp + git clone --depth=1 https://github.com/gopherjs/todomvc.git + cd /tmp/todomvc + gopherjs build -v -o /tmp/todomvc_gomod.js github.com/gopherjs/todomvc + gopherjs test -v github.com/gopherjs/todomvc/... + - name: TodoMVC in Modules mode + if: matrix.os == 'windows-latest' + run: | + $ErrorActionPreference = "Stop" + Set-Location C:\tmp + git clone --depth=1 https://github.com/gopherjs/todomvc.git + Set-Location C:\tmp\todomvc + gopherjs build -v -o C:\tmp\todomvc_gomod.js github.com/gopherjs/todomvc + gopherjs test -v github.com/gopherjs/todomvc/... + - name: Go Repository tests + run: | + go test -v github.com/gopherjs/gopherjs/tests/gorepo + + - name: Download JUnit Summary from Previous Workflow + if: matrix.index + id: download-artifact + uses: dawidd6/action-download-artifact@v2 + with: + workflow_conclusion: success + name: junit-test-summary + if_no_artifact_found: warn + # Uncomment the next line before pushing to main branch, that way all branches can + # benefit from timing data once it's established there. + # branch: main + + - name: Install gotestsum + if: matrix.index + run: go install gotest.tools/gotestsum@latest + - name: Generate go test Slice + if: matrix.index + id: test_split + env: + GOOS: js + GOARCH: ecmascript + uses: hashicorp-forge/go-test-split-action@v1 + with: + total: 4 + index: ${{ matrix.index }} + packages: "std github.com/gopherjs/gopherjs/js/... github.com/gopherjs/gopherjs/tests/..." + - name: gopherjs test ... + if: matrix.index + run: | + set -e + ulimit -s 10000 + + PACKAGE_NAMES=$(for pkg in ${{ steps.test_split.outputs.run }}; do echo "$pkg"; done | grep -v -x -f .std_test_pkg_exclusions) + + gopherjs test -p 2 --minify -v --short "${{ steps.test_split.outputs.run }}" diff --git a/circle.yml b/circle.yml index 12b0aa45f..98b29b114 100644 --- a/circle.yml +++ b/circle.yml @@ -41,15 +41,6 @@ workflows: - gopherjs_tests: requires: - build - - gorepo_tests: - requires: - - build - - darwin_smoke: - requires: - - build - - windows_smoke: - requires: - - build parameters: go_version: @@ -72,27 +63,6 @@ jobs: executor: gopherjs steps: - setup_and_install_gopherjs - - run: - name: Check natives build tags - command: diff -u <(echo -n) <(go list ./compiler/natives/src/...) # All those packages should have // +build js. - - run: - name: Smoke tests - command: | - gopherjs build -v net/http # Should build successfully. - gopherjs test -v fmt log # Should catch problems with test execution and source maps. - - run: - name: go test ... - command: | - set +e - # Run all tests except gorepo, which will be run separately in parallel. - go test -v -race $(go list ./... | grep -v github.com/gopherjs/gopherjs/tests/gorepo) | tee /tmp/test-go.txt - status="$?" - # Convert test output into junit format for CircleCI. - mkdir -p ~/test-reports/ - go-junit-report --full-class-name < /tmp/test-go.txt > ~/test-reports/go.xml - exit "$status" - - store_test_results: - path: ~/test-reports/ - run: name: TodoMVC in GOPATH mode command: | @@ -149,74 +119,6 @@ jobs: - store_test_results: path: ~/test-reports/ - gorepo_tests: - executor: gopherjs - parallelism: 4 - steps: - - setup_environment - - checkout - - install_deps - - install_gopherjs - - run: - name: Go Repository tests - command: | - go test -v github.com/gopherjs/gopherjs/tests/gorepo - - windows_smoke: - executor: - name: win/default - shell: powershell.exe - steps: - - checkout - - run: - name: Install Go - command: | - choco install golang --version="<< pipeline.parameters.go_version >>" -my - go version - (Get-Command go).Path - [Environment]::SetEnvironmentVariable( - "Path", - [Environment]::GetEnvironmentVariable("Path", [EnvironmentVariableTarget]::Machine) + ";C:\Users\circleci\go\bin", - [EnvironmentVariableTarget]::Machine) - - - install_deps: - optional: false - - run: - name: Install GopherJS - command: - go install -v . - (Get-Command gopherjs).Path - - run: - name: Test GopherJS - command: go test -v -short ./... - - run: - name: Smoke tests - command: | - $env:NODE_PATH=$(npm root) - $env:SOURCE_MAP_SUPPORT=false - gopherjs build -v net/http - gopherjs test -v --short fmt sort ./tests - - darwin_smoke: - macos: - xcode: 13.4.1 # Mac OS 12.6.1, see https://circleci.com/docs/using-macos/ - steps: - - checkout - - setup_environment - - install_deps: - optional: false - - run: - name: Install GopherJS - command: go install -v . - - run: - name: Test GopherJS - command: go test -v -short ./... - - run: - name: Smoke tests - command: | - gopherjs build -v net/http - gopherjs test -v --short fmt log os ./tests - commands: setup_environment: description: Set up Go, NVM and Node.js