Skip to content

[go1.20] Pull master into go1.20 to get the CI update #1326

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions .github/actions/setup-gopherjs/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Setup GopherJS
description: Sets up Go, Node.js, and GopherJS

inputs:
includeSyscall:
description: Indicates that the node-syscall package should be installed.
required: true
default: 'false'

fixTemps:
description: Indicates that the Windows Temp variables should be fixed.
required: true
default: 'false'

runs:
using: composite
steps:
- name: Fix Windows Temp Variables
if: inputs.fixTemps == 'true'
shell: pwsh
run: |
# see https://github.com/actions/runner-images/issues/712#issuecomment-613004302
echo "TEMP=$env:USERPROFILE\AppData\Local\Temp" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
echo "TMP=$env:USERPROFILE\AppData\Local\Temp" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
echo "TMPDIR=$env:USERPROFILE\AppData\Local\Temp" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}

- name: Setup Go Environment
working-directory: ${{ env.GOPHERJS_PATH }}
shell: bash
run: echo "GOROOT=$(go env GOROOT)" >> $GITHUB_ENV

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}

- name: Install Node.js for non-Linux
if: inputs.includeSyscall != 'true'
working-directory: ${{ env.GOPHERJS_PATH }}
shell: bash
# Install required Node.js packages without optional (node-syscall).
run: npm install --omit=optional --no-package-lock

- name: Install Node.js for Linux
if: inputs.includeSyscall == 'true'
working-directory: ${{ env.GOPHERJS_PATH }}
shell: bash
# Install required Node.js packages including optional (node-syscall).
run: |
npm install --include=optional --no-package-lock

- name: Setup Node.js Environment
working-directory: ${{ env.GOPHERJS_PATH }}
shell: bash
# Make nodejs able to require installed modules from any working path.
run: echo "NODE_PATH=$(npm root)" >> $GITHUB_ENV

- name: Install GopherJS
working-directory: ${{ env.GOPHERJS_PATH }}
shell: bash
run: go install -v

- name: Setup information
shell: bash
run: |
echo ::notice::go version: $(go version)
echo ::notice::node version: $(node -v)
echo ::notice::npm version: $(npm -v)
echo ::notice::gopherjs version: $(gopherjs version)
221 changes: 221 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,221 @@
name: CI

on:
push:
branches: [ "*" ]
pull_request:
branches: [ "*" ]

permissions:
contents: read

concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true

env:
GO_VERSION: 1.20.14
NODE_VERSION: 12
GOLANGCI_VERSION: v1.53.3
GOPHERJS_EXPERIMENT: generics
SOURCE_MAP_SUPPORT: true
GOPATH: ${{ github.workspace }}/go
GOPHERJS_PATH: ${{ github.workspace }}/go/src/github.com/${{ github.repository }}

jobs:
ubuntu_smoke:
name: Ubuntu Smoke
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
path: ${{ env.GOPHERJS_PATH }}
- name: Copy Actions
run: cp -r ${{ env.GOPHERJS_PATH }}/.github .
- name: Setup GopherJS
uses: ./.github/actions/setup-gopherjs/
with:
includeSyscall: 'true'
- name: Test GopherJS
working-directory: ${{ env.GOPHERJS_PATH }}
run: go test -v -short ./...
- name: Run Tests
working-directory: ${{ env.GOPHERJS_PATH }}
run: |
gopherjs build -v net/http
gopherjs test -v --short fmt log ./tests

windows_smoke:
name: Window Smoke
runs-on: windows-latest
env:
# Windows does not support source maps.
SOURCE_MAP_SUPPORT: false
steps:
- uses: actions/checkout@v4
with:
path: ${{ env.GOPHERJS_PATH }}
- name: Copy Actions
run: cp -r ${{ env.GOPHERJS_PATH }}/.github .
- name: Setup GopherJS
uses: ./.github/actions/setup-gopherjs/
with:
fixTemps: 'true'
- name: Test GopherJS
working-directory: ${{ env.GOPHERJS_PATH }}
run: go test -v -short ./...
- name: Run Tests
working-directory: ${{ env.GOPHERJS_PATH }}
run: |
gopherjs build -v net/http
gopherjs test -v --short fmt sort ./tests

darwin_smoke:
name: Darwin Smoke
runs-on: macos-latest
env:
# Node version '12' is not found for darwin.
NODE_VERSION: 20
steps:
- uses: actions/checkout@v4
with:
path: ${{ env.GOPHERJS_PATH }}
- name: Copy Actions
run: cp -r ${{ env.GOPHERJS_PATH }}/.github .
- name: Setup GopherJS
uses: ./.github/actions/setup-gopherjs/
- name: Test GopherJS
working-directory: ${{ env.GOPHERJS_PATH }}
run: go test -v -short ./...
- name: Run Tests
working-directory: ${{ env.GOPHERJS_PATH }}
run: |
gopherjs build -v net/http
gopherjs test -v --short fmt log os ./tests

lint:
name: Lint Checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
path: ${{ env.GOPHERJS_PATH }}
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: Install golangci-lint
uses: golangci/golangci-lint-action@v3
with:
working-directory: ${{ env.GOPHERJS_PATH }}
version: ${{ env.GOLANGCI_VERSION }}
only-new-issues: true
- name: Check go.mod
working-directory: ${{ env.GOPHERJS_PATH }}
run: go mod tidy && git diff --exit-code
- name: Check natives build tags
working-directory: ${{ env.GOPHERJS_PATH }}
# All those packages should have // +build js.
run: diff -u <(echo -n) <(go list ./compiler/natives/src/...)

go_tests:
name: Go Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
path: ${{ env.GOPHERJS_PATH }}
- name: Copy Actions
run: cp -r ${{ env.GOPHERJS_PATH }}/.github .
- name: Setup GopherJS
uses: ./.github/actions/setup-gopherjs/
- name: Run Tests
working-directory: ${{ env.GOPHERJS_PATH }}
# Run all tests except gorepo tests.
run: go test -v -race $(go list ./... | grep -v github.com/gopherjs/gopherjs/tests/gorepo)

todomvc_check:
name: TodoMVC GO111MODULE Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
path: ${{ env.GOPHERJS_PATH }}
- name: Copy Actions
run: cp -r ${{ env.GOPHERJS_PATH }}/.github .
- name: Setup GopherJS
uses: ./.github/actions/setup-gopherjs/
- name: TodoMVC in GOPATH mode
working-directory: ${{ env.GOPHERJS_PATH }}
env:
GO111MODULE: off
GOPATH: /tmp/gopath
run: |
mkdir -p $GOPATH/src/github.com/gopherjs/gopherjs
cp -r -p ${{ env.GOPHERJS_PATH }}/. $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/...
find $GOPATH
- name: TodoMVC in Go Modules mode
env:
GO111MODULE: on
GOPATH: /tmp/gmod
run: |
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
- name: Compare GOPATH and Go Modules output
run: |
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:
name: GopherJS Tests (${{ matrix.filter.name }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
filter:
- name: non-crypto
pattern: '-Pve "^crypto"'
- name: cypto
pattern: '-Pe "^crypto"'
steps:
- uses: actions/checkout@v4
with:
path: ${{ env.GOPHERJS_PATH }}
- name: Copy Actions
run: cp -r ${{ env.GOPHERJS_PATH }}/.github .
- name: Setup GopherJS
uses: ./.github/actions/setup-gopherjs/
- name: Run GopherJS tests
working-directory: ${{ env.GOPHERJS_PATH }}
run: |
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 \
| grep ${{ matrix.filter.pattern }} \
)
echo "Running tests for packages:"
echo "$PACKAGE_NAMES"
gopherjs test -p 4 --minify -v --short $PACKAGE_NAMES

gorepo_tests:
name: Gorepo Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
path: ${{ env.GOPHERJS_PATH }}
- name: Copy Actions
run: cp -r ${{ env.GOPHERJS_PATH }}/.github .
- name: Setup GopherJS
uses: ./.github/actions/setup-gopherjs/
- name: Run GopherJS tests
working-directory: ${{ env.GOPHERJS_PATH }}
run: go test -v github.com/gopherjs/gopherjs/tests/gorepo
25 changes: 0 additions & 25 deletions .github/workflows/lint.yaml

This file was deleted.

12 changes: 7 additions & 5 deletions .github/workflows/measure-size.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,29 @@ name: Measure canonical app size

on: ['pull_request']

env:
GO_VERSION: '~1.20.14'

jobs:
measure:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-go@v2
- uses: actions/setup-go@v5
with:
go-version: '~1.20.14'
go-version: ${{ env.GO_VERSION }}
- 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
- uses: actions/upload-artifact@v4
with:
name: size_report
path: |
/tmp/report.json
/tmp/report.md

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![GoDoc](https://godoc.org/github.com/gopherjs/gopherjs/js?status.svg)](https://godoc.org/github.com/gopherjs/gopherjs/js)
[![Sourcegraph](https://sourcegraph.com/github.com/gopherjs/gopherjs/-/badge.svg)](https://sourcegraph.com/github.com/gopherjs/gopherjs?badge)
[![Circle CI](https://circleci.com/gh/gopherjs/gopherjs.svg?style=svg)](https://circleci.com/gh/gopherjs/gopherjs)
[![Github Actions CI](https://github.com/gopherjs/gopherjs/actions/workflows/ci.yaml/badge.svg)](https://github.com/gopherjs/gopherjs/actions/workflows/ci.yaml)

GopherJS compiles Go code ([go.dev](https://go.dev/)) to pure JavaScript code. Its main purpose is to give you the opportunity to write front-end code in Go which will still run in all browsers.

Expand Down
Loading
Loading