github.com/gopherjs/gopherjs@v1.19.0-beta1.0.20240506212314-27071a8796e4/circle.yml (about)

     1  # CircleCI configuration for GopherJS.
     2  #
     3  # This configuration has one build_and_test workflow designed to run on all commits
     4  # and pull requests. It consists of three jobs:
     5  #
     6  #  - build: Builds and runs GopherJS unit tests, as well as lints, smoke tests, etc.
     7  #    This job is designed to provide quickest feedback on the most important
     8  #    functionality. It should not include anything heavyweight and should be kept
     9  #    under 2-3 minutes of runtime.
    10  #
    11  #  - gopherjs_tests: Runs standard library and GopherJS package tests using GopherJS
    12  #    *itself*. This is the most comprehensive test suite we have, and it is sharded
    13  #    into 4 parallel instances for faster execution.
    14  #
    15  #  - gorepo_tests: Runs language tests from the Go compiler test suite. The objective
    16  #    of these tests is to ensure conformance of GopherJS to the upstream Go to the
    17  #    highest degree possible, considering differences in the runtime.
    18  #
    19  # If all tests passed, it is reasonably to assume that the version is more or less
    20  # bug-free (although as of summer 2021 our test coverage is not ideal).
    21  #
    22  # For convenience of upgrades, NVM, Node.js and Go versions are specified as
    23  # parameters at the top of the config. Increasing the version and ensuring that the
    24  # workflow passes is sufficient to verify GopherJS compatibility with that version.
    25  #
    26  # Versions of Node modules GopherJS depends on are specified in package.json and can
    27  # be changed there (remember to run `npm install` to update the lock file).
    28  
    29  version: 2.1
    30  executors:
    31    gopherjs:
    32      docker:
    33      - image: cimg/base:stable
    34      working_directory: ~/gopherjs
    35  
    36  workflows:
    37    version: 2
    38    build_and_test:
    39      jobs:
    40      - build
    41      - gopherjs_tests:
    42          requires:
    43            - build
    44      - gorepo_tests:
    45          requires:
    46            - build
    47      - darwin_smoke:
    48          requires:
    49            - build
    50      - windows_smoke:
    51          requires:
    52            - build
    53  
    54  parameters:
    55    go_version:
    56      type: string
    57      default: "1.19.13"
    58    chocolatey_go_version:
    59      type: string
    60      # Chocolatey doesn't have 1.19.13, closest is 1.19.9
    61      default: "1.19.9"
    62    nvm_version:
    63      type: string
    64      default: "0.38.0"
    65    node_version:
    66      type: string
    67      default: "12"
    68  
    69  orbs:
    70    win: circleci/windows@4.0.0
    71    go: circleci/go@1.7.1
    72    node: circleci/node@5.0.1
    73  
    74  jobs:
    75    build:
    76      executor: gopherjs
    77      environment:
    78        GOPHERJS_EXPERIMENT: generics
    79      steps:
    80      - setup_and_install_gopherjs
    81      - run:
    82          name: Check natives build tags
    83          command: diff -u <(echo -n) <(go list ./compiler/natives/src/...) # All those packages should have // +build js.
    84      - run:
    85          name: Smoke tests
    86          command: |
    87            gopherjs build -v net/http # Should build successfully.
    88            gopherjs test -v fmt log # Should catch problems with test execution and source maps.
    89      - run:
    90          name: go test ...
    91          command: |
    92            set +e
    93            # Run all tests except gorepo, which will be run separately in parallel.
    94            go test -v -race $(go list ./... | grep -v github.com/gopherjs/gopherjs/tests/gorepo) | tee /tmp/test-go.txt
    95            status="$?"
    96            # Convert test output into junit format for CircleCI.
    97            mkdir -p ~/test-reports/
    98            go-junit-report --full-class-name < /tmp/test-go.txt > ~/test-reports/go.xml
    99            exit "$status"
   100      - store_test_results:
   101          path: ~/test-reports/
   102      - run:
   103          name: TodoMVC in GOPATH mode
   104          command: |
   105            set -e
   106            export GO111MODULE=off
   107            export GOPATH=/tmp/gopath
   108            mkdir -p $GOPATH/src/github.com/gopherjs/gopherjs
   109            cp -r -p . $GOPATH/src/github.com/gopherjs/gopherjs/
   110            go get -v github.com/gopherjs/todomvc
   111            gopherjs build -v -o /tmp/todomvc_gopath.js github.com/gopherjs/todomvc
   112            gopherjs test -v github.com/gopherjs/todomvc/...
   113            find $GOPATH
   114      - run:
   115          name: TodoMVC in Go Modules mode
   116          command: |
   117            set -e
   118            export GO111MODULE=on
   119            export GOPATH=/tmp/gomod
   120            mkdir -p $GOPATH/src
   121            cd /tmp
   122            git clone --depth=1 https://github.com/gopherjs/todomvc.git
   123            cd /tmp/todomvc
   124            gopherjs build -v -o /tmp/todomvc_gomod.js github.com/gopherjs/todomvc
   125            gopherjs test -v github.com/gopherjs/todomvc/...
   126            find $GOPATH
   127      - run:
   128          name: Compare GOPATH and Go Modules output
   129          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)
   130  
   131    gopherjs_tests:
   132      executor: gopherjs
   133      parallelism: 4
   134      environment:
   135        GOPHERJS_EXPERIMENT: generics
   136      steps:
   137      - setup_and_install_gopherjs
   138      - run:
   139          name: gopherjs test ...
   140          command: |
   141            set +e
   142            ulimit -s 10000
   143            PACKAGE_NAMES=$( \
   144              GOOS=js GOARCH=wasm go list std github.com/gopherjs/gopherjs/js/... github.com/gopherjs/gopherjs/tests/... \
   145              | grep -v -x -f .std_test_pkg_exclusions \
   146              | circleci tests split --split-by=timings --timings-type=classname \
   147            )
   148            gopherjs test -p 2 --minify -v --short $PACKAGE_NAMES \
   149              | tee /tmp/test-gopherjs.txt
   150            status="$?"
   151            set -e
   152            # Convert test output into junit format for CircleCI.
   153            mkdir -p ~/test-reports/
   154            go-junit-report --full-class-name < /tmp/test-gopherjs.txt > ~/test-reports/gopherjs-${CIRCLE_NODE_INDEX}.xml
   155            exit "$status"
   156          no_output_timeout: "1h"  # Packages like math/big take a while to run all tests.
   157      - store_test_results:
   158          path: ~/test-reports/
   159  
   160    gorepo_tests:
   161      executor: gopherjs
   162      environment:
   163        GOPHERJS_EXPERIMENT: generics
   164      parallelism: 4
   165      steps:
   166      - setup_environment
   167      - checkout
   168      - install_deps
   169      - install_gopherjs
   170      - run:
   171          name: Go Repository tests
   172          command: |
   173            go test -v github.com/gopherjs/gopherjs/tests/gorepo
   174  
   175    windows_smoke:
   176      executor:
   177        name: win/default
   178        shell: powershell.exe
   179      environment:
   180        GOPHERJS_EXPERIMENT: generics
   181      steps:
   182        - checkout
   183        - run:
   184            name: Install Go
   185            command: |
   186              choco install golang --version="<< pipeline.parameters.chocolatey_go_version >>" -my --force -y
   187              go version
   188              (Get-Command go).Path
   189              [Environment]::SetEnvironmentVariable(
   190                "Path",
   191                [Environment]::GetEnvironmentVariable("Path", [EnvironmentVariableTarget]::Machine) + ";C:\Users\circleci\go\bin",
   192                [EnvironmentVariableTarget]::Machine)
   193  
   194        - install_deps:
   195            optional: false
   196        - run: 
   197            name: Install GopherJS
   198            command: 
   199              go install -v .
   200              (Get-Command gopherjs).Path
   201        - run: 
   202            name: Test GopherJS
   203            command: go test -v -short ./...
   204        - run:
   205            name: Smoke tests
   206            command: |
   207              $env:NODE_PATH=$(npm root)
   208              $env:SOURCE_MAP_SUPPORT=false
   209              gopherjs build -v net/http
   210              gopherjs test -v --short fmt sort ./tests
   211      
   212    darwin_smoke:
   213      macos:
   214        xcode: 13.4.1 # Mac OS 12.6.1, see https://circleci.com/docs/using-macos/
   215      environment:
   216        GOPHERJS_EXPERIMENT: generics
   217      steps:
   218        - checkout
   219        - setup_environment
   220        - install_deps:
   221            optional: false
   222        - run: 
   223            name: Install GopherJS
   224            command: go install -v .
   225        - run: 
   226            name: Test GopherJS
   227            command: go test -v -short ./...
   228        - run:
   229            name: Smoke tests
   230            command: |
   231              gopherjs build -v net/http
   232              gopherjs test -v --short fmt log os ./tests
   233  
   234  commands:
   235    setup_environment:
   236      description: Set up Go, NVM and Node.js
   237      steps:
   238      - go/install:
   239          version: << pipeline.parameters.go_version >>
   240      - node/install:
   241          node-version: << pipeline.parameters.node_version >>
   242      - run:
   243          name: Set up environment
   244          command: |
   245            echo 'export PATH="$PATH:$HOME/go/bin"' >> $BASH_ENV
   246            echo 'export GO111MODULE=on' >> $BASH_ENV
   247            echo 'export SOURCE_MAP_SUPPORT=true' >> $BASH_ENV
   248            # Make nodejs able to require installed modules from any working path.
   249            echo "export NODE_PATH=$(npm root)" >> $BASH_ENV
   250            go version
   251            node -v
   252            go install -v github.com/nevkontakte/go-junit-report@forked # For CircleCI test reports.
   253    install_deps:
   254      description: Install Go and Node dependency packages
   255      parameters:
   256        optional:
   257          default: true
   258          type: boolean
   259          description: Install node-syscall module and its dependencies.
   260      steps:
   261      - when:
   262          condition:
   263            not: << parameters.optional >>
   264          steps:
   265          - run:
   266              name: Install required Node.js packages
   267              command: |
   268                # Extra flags to avoid installing node-syscall.
   269                npm install --no-optional --no-package-lock
   270      - when:
   271          condition: << parameters.optional >>
   272          steps:
   273          - run:
   274              name: Install required Node.js packages (including optional)
   275              command: |
   276                npm ci # Install our dependencies from package.json.
   277      - go/mod-download
   278    install_gopherjs:
   279      description: Install GopherJS
   280      steps:
   281      - run:
   282          name: Install GopherJS
   283          command: go install -v && gopherjs version
   284    setup_and_install_gopherjs:
   285      description: A shorthand for setting up GopherJS environment and building the binary.
   286      steps:
   287      - setup_environment
   288      - checkout
   289      - install_deps
   290      - install_gopherjs