| # CircleCI configuration for GopherJS. |
| # |
| # This configuration has one build_and_test workflow designed to run on all commits |
| # and pull requests. It consists of three jobs: |
| # |
| # - build: Builds and runs GopherJS unit tests, as well as lits, smoke tests, etc. |
| # This job is designed to provide quickest feedback on the most important |
| # functionality. It should not include anything heavyweight and should be kept |
| # under 2-3 minutes of runtime. |
| # |
| # - gopherjs_tests: Runs standard library and GopherJS package tests using GopherJS |
| # *itself*. This is the most comprehensive test suite we have and it is sharded |
| # into 4 parallel instances for faster execution. |
| # |
| # - gorepo_tests: Runs language tests from the Go compiler test suite. The objective |
| # of these tests is to ensure conformance of GopherJS to the upstream Go to the |
| # highest degree possible, considering differences in the runtime. |
| # |
| # If all tests passed, it is reasonably to assume that the version is more or less |
| # bug-free (although as of summer 2021 our test coverage is not ideal). |
| # |
| # For convenience of upgrades, NVM, Node.js and Go versions are specified as |
| # parameters at the top of the config. Increasing the version and ensuring that the |
| # workflow passes is sufficient to verify GopherJS compatibility with that version. |
| # |
| # Versions of Node modules GopherJS depends on are specified in package.json and can |
| # be changed there (remember to run `npm install` to update the lock file). |
| |
| version: 2.1 |
| executors: |
| gopherjs: |
| docker: |
| - image: cimg/base:stable |
| working_directory: ~/gopherjs |
| |
| workflows: |
| version: 2 |
| build_and_test: |
| jobs: |
| - build |
| - gopherjs_tests: |
| requires: |
| - build |
| - gorepo_tests: |
| requires: |
| - build |
| - darwin_smoke: |
| requires: |
| - build |
| - windows_smoke: |
| requires: |
| - build |
| |
| parameters: |
| go_version: |
| type: string |
| default: "1.18.5" |
| nvm_version: |
| type: string |
| default: "0.38.0" |
| node_version: |
| type: string |
| default: "12" |
| |
| orbs: |
| win: circleci/windows@4.0.0 |
| go: circleci/go@1.7.1 |
| node: circleci/node@5.0.1 |
| |
| jobs: |
| build: |
| executor: gopherjs |
| steps: |
| - setup_and_install_gopherjs |
| - run: |
| name: Check minified prelude |
| command: | |
| set -e |
| go generate github.com/gopherjs/gopherjs/compiler/prelude |
| diff -u <(echo -n) <(git status --porcelain) |
| - run: |
| name: Check gofmt |
| command: diff -u <(echo -n) <(gofmt -d .) |
| - run: |
| name: Check go vet |
| command: | |
| set -e |
| # Go package in root directory. |
| go vet . |
| # All subdirectories except "doc", "tests", "node*". |
| for d in */; do echo ./$d...; done | grep -v ./doc | grep -v ./tests | grep -v ./node | xargs go vet |
| - 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: | |
| set -e |
| export GO111MODULE=off |
| export GOPATH=/tmp/gopath |
| mkdir -p $GOPATH/src |
| 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/... |
| find $GOPATH |
| - run: |
| name: TodoMVC in Go Modules mode |
| command: | |
| set -e |
| export GO111MODULE=on |
| export GOPATH=/tmp/gomod |
| mkdir -p $GOPATH/src |
| 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/... |
| find $GOPATH |
| - run: |
| name: Compare GOPATH and Go Modules output |
| command: diff -u <(sed 's/todomvc_gomod.js.map/todomvc_ignored.js.map/' /tmp/todomvc_gomod.js) <(sed 's/todomvc_gopath.js.map/todomvc_ignored.js.map/' /tmp/todomvc_gopath.js) |
| |
| gopherjs_tests: |
| executor: gopherjs |
| parallelism: 4 |
| steps: |
| - setup_and_install_gopherjs |
| - run: |
| name: gopherjs test ... |
| command: | |
| set +e |
| ulimit -s 10000 |
| PACKAGE_NAMES=$( \ |
| GOOS=js GOARCH=wasm go list std github.com/gopherjs/gopherjs/js/... github.com/gopherjs/gopherjs/tests/... \ |
| | grep -v -x -f .std_test_pkg_exclusions \ |
| | circleci tests split --split-by=timings --timings-type=classname \ |
| ) |
| gopherjs test -p 2 --minify -v --short $PACKAGE_NAMES \ |
| | tee /tmp/test-gopherjs.txt |
| status="$?" |
| set -e |
| # Convert test output into junit format for CircleCI. |
| mkdir -p ~/test-reports/ |
| go-junit-report --full-class-name < /tmp/test-gopherjs.txt > ~/test-reports/gopherjs-${CIRCLE_NODE_INDEX}.xml |
| exit "$status" |
| no_output_timeout: "1h" # Packages like math/big take a while to run all tests. |
| - 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.3.0 # Mac OS 12.2.1 |
| 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 |
| steps: |
| - go/install: |
| version: << pipeline.parameters.go_version >> |
| - node/install: |
| node-version: << pipeline.parameters.node_version >> |
| - run: |
| name: Set up environment |
| command: | |
| echo 'export PATH="$PATH:$HOME/go/bin"' >> $BASH_ENV |
| echo 'export GO111MODULE=on' >> $BASH_ENV |
| echo 'export SOURCE_MAP_SUPPORT=true' >> $BASH_ENV |
| # Make nodejs able to require installed modules from any working path. |
| echo "export NODE_PATH=$(npm root)" >> $BASH_ENV |
| go version |
| node -v |
| go install -v github.com/nevkontakte/go-junit-report@forked # For CircleCI test reports. |
| install_deps: |
| description: Install Go and Node dependency packages |
| parameters: |
| optional: |
| default: true |
| type: boolean |
| description: Install node-syscall module and its dependencies. |
| steps: |
| - when: |
| condition: |
| not: << parameters.optional >> |
| steps: |
| - run: |
| name: Install required Node.js packages |
| command: | |
| # Extra flags to avoid installing node-syscall. |
| npm install --no-optional --no-package-lock |
| - when: |
| condition: << parameters.optional >> |
| steps: |
| - run: |
| name: Install required Node.js packages (including optional) |
| command: | |
| npm ci # Install our dependencies from package.json. |
| - go/mod-download |
| install_gopherjs: |
| description: Install GopherJS |
| steps: |
| - run: |
| name: Install GopherJS |
| command: go install -v && gopherjs version |
| setup_and_install_gopherjs: |
| description: A shorthand for setting up GopherJS environment and building the binary. |
| steps: |
| - setup_environment |
| - checkout |
| - install_deps |
| - install_gopherjs |