From a886ea671623d60100d095c2102ea93c2438e676 Mon Sep 17 00:00:00 2001 From: Grant Nelson Date: Thu, 13 Jun 2024 15:58:37 -0600 Subject: [PATCH] working on ci workflow --- .github/actions/setup-gopherjs/action.yml | 42 +++++++++++ .github/workflows/ci.yaml | 87 +++++++++++++++++++++++ .github/workflows/lint.yaml | 29 -------- .github/workflows/windows-test.yml | 52 -------------- 4 files changed, 129 insertions(+), 81 deletions(-) create mode 100644 .github/actions/setup-gopherjs/action.yml create mode 100644 .github/workflows/ci.yaml delete mode 100644 .github/workflows/lint.yaml delete mode 100644 .github/workflows/windows-test.yml diff --git a/.github/actions/setup-gopherjs/action.yml b/.github/actions/setup-gopherjs/action.yml new file mode 100644 index 000000000..4823e8532 --- /dev/null +++ b/.github/actions/setup-gopherjs/action.yml @@ -0,0 +1,42 @@ +name: Setup GopherJS +description: Sets up Go, Node.js, and GopherJS +runs: + using: composite + steps: + + - uses: actions/setup-go@v5 + with: + go-version: ${{ env.GO_VERSION }} + + - uses: actions/setup-node@v4 + with: + node-version: ${{ env.NODE_VERSION }} + + - name: Setup Node.js + # Make nodejs able to require installed modules from any working path + # and set extra flags to avoid installing node-syscall. + shell: bash + run: | + echo "NODE_PATH=$(npm root)" >> $GITHUB_ENV + npm install --no-optional --no-package-lock + + - name: Fix TEMP variable + # see https://github.com/actions/runner-images/issues/712#issuecomment-613004302 + shell: bash + if: ${{ inputs.os }} == 'windows-latest' + run: | + 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 + + - name: Install GopherJS + shell: bash + run: go install -v + + - name: Setup information + shell: bash + run: | + echo ::notice::$(go version) + echo ::notice::$(node -v) + echo ::notice::$(npm -v) + echo ::notice::$(gopherjs version) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 000000000..752f432fe --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,87 @@ +name: CI + +on: + push: + branches: [ "*" ] + pull_request: + branches: [ "*" ] + +permissions: + contents: read + +env: + GO_VERSION: 1.19.13 + NODE_VERSION: 20 + 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: + build: + name: Build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Setup GopherJS + uses: ./.github/actions/setup-gopherjs/ + - name: Test GopherJS + run: go test -v -short ./... + - name: Smoke tests + run: | + gopherjs build -v net/http + gopherjs test -v --short fmt log os ./tests + + lint: + name: Lint Checks + needs: build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Setup GopherJS + uses: ./.github/actions/setup-gopherjs/ + # Uncomment when not in Workiva/gopherjs fork + #- name: Install golangci-lint + # uses: golangci/golangci-lint-action@v3 + # with: + # version: ${{ env.GOLANGCI_VERSION }} + # only-new-issues: true + - name: Check go.mod + run: go mod tidy && git diff --exit-code + - name: Check natives build tags + # All those packages should have // +build js. + run: diff -u <(echo -n) <(go list ./compiler/natives/src/...) + + windows_smoke: + name: Windows Smoke + needs: build + runs-on: windows-latest + env: + SOURCE_MAP_SUPPORT: false + steps: + - uses: actions/checkout@v4 + - name: Setup GopherJS + uses: ./.github/actions/setup-gopherjs/ + - name: Test GopherJS + run: go test -v -short ./... + - name: Smoke tests + run: | + gopherjs build -v net/http + gopherjs test -v --short fmt sort ./tests + + darwin_smoke: + name: Darwin Smoke + needs: build + runs-on: macos-latest + steps: + - uses: actions/checkout@v4 + - name: Setup GopherJS + uses: ./.github/actions/setup-gopherjs/ + - name: Test GopherJS + run: | + go test -v -short ./... + - name: Smoke tests + run: | + gopherjs build -v net/http + gopherjs test -v --short fmt log os ./tests diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml deleted file mode 100644 index 0e2af1ec4..000000000 --- a/.github/workflows/lint.yaml +++ /dev/null @@ -1,29 +0,0 @@ -name: Lint Checks -on: - pull_request: -permissions: - contents: read -jobs: - golangci: - name: lint - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - - uses: actions/setup-go@v3 - with: - go-version: "1.19.13" - - - name: golangci-lint - uses: golangci/golangci-lint-action@v3 - with: - version: v1.53.3 - only-new-issues: true - - - 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/windows-test.yml b/.github/workflows/windows-test.yml deleted file mode 100644 index b0d3de6f3..000000000 --- a/.github/workflows/windows-test.yml +++ /dev/null @@ -1,52 +0,0 @@ -name: Windows OS Test - -on: - push: - branches: [ "*" ] - pull_request: - branches: [ "*" ] - -permissions: - contents: read - -env: - GO_VERSION: 1.19.13 - NODE_VERSION: 12 - SOURCE_MAP_SUPPORT: false - GOPATH: ${{ github.workspace }}/go - GOPHERJS_PATH: ${{ github.workspace }}/go/src/github.com/${{ github.repository }} - # Fix TEMP variable, see https://github.com/actions/runner-images/issues/712#issuecomment-613004302 - TEMP: \%USERPROFILE%\AppData\Local\Temp - TMP: \%USERPROFILE%\AppData\Local\Temp - TMPDIR: \%USERPROFILE%\AppData\Local\Temp - -jobs: - tests: - name: tests - runs-on: windows-latest - - steps: - - uses: actions/setup-go@v3 - with: - go-version: ${{ env.GO_VERSION }} - - uses: actions/setup-node@v3 - with: - node-version: ${{ env.NODE_VERSION }} - - uses: actions/checkout@v3 - - name: Set up environment - run: | - # Make nodejs able to require installed modules from any working path. - echo "NODE_PATH=$(npm root)" >> $GITHUB_ENV - echo ::notice::$(npm root) - echo ::notice::$(go version) - echo ::notice::$(node -v) - echo ::notice::$(npm -v) - - name: Build and Install GopherJS - run: | - go install -v - echo ::notice::$(gopherjs version) - - name: Smoke tests - run: | - gopherjs build -v net/http - gopherjs test -v --short fmt sort ./tests -