From 0ec1c69c0635c0ee5c209b5f1198fde1acfaf321 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Thu, 7 May 2020 20:44:32 -0400 Subject: [PATCH] Switch fully to GH Actions --- .github/workflows/ci.yaml | 57 +++++++++++++-- .travis.yml | 80 ---------------------- ci/README.md | 12 ++-- ci/container/Dockerfile | 63 ++++++++++------- ci/container/exec.sh | 24 ------- ci/dev/vscode.patch | 16 +++++ ci/release-container/Dockerfile | 7 +- ci/steps/linux-release.sh | 13 ---- ci/steps/publish-npm.sh | 11 --- ci/steps/{static-release.sh => release.sh} | 4 ++ 10 files changed, 115 insertions(+), 172 deletions(-) delete mode 100644 .travis.yml delete mode 100755 ci/container/exec.sh delete mode 100755 ci/steps/linux-release.sh delete mode 100755 ci/steps/publish-npm.sh rename ci/steps/{static-release.sh => release.sh} (81%) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index c8c3b39f..c0a107ac 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -3,13 +3,60 @@ name: ci on: [push, pull_request] jobs: - arm64-release: - name: linux-arm64-release - runs-on: [Linux, ARM64] + test: + runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 - - run: ./ci/steps/linux-release.sh - - uses: actions/upload-artifact@v2 + - name: Run ./ci/steps/test.sh + uses: ./ci/container + with: + args: ./ci/steps/test.sh + + linux-amd64: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: Run ./ci/steps/release.sh + uses: ./ci/container + with: + args: ./ci/steps/release.sh + - name: Upload release artifacts + uses: actions/upload-artifact@v2 + with: + name: release-github + path: ./release-github/* + - name: Upload npm package artifact + uses: actions/upload-artifact@v2 + with: + name: npm-package + path: ./release + + linux-arm64: + runs-on: ubuntu-arm64-latest + steps: + - uses: actions/checkout@v1 + - name: Run ./ci/steps/release.sh + uses: ./ci/container + with: + args: ./ci/steps/release.sh + - name: Upload release artifacts + uses: actions/upload-artifact@v2 + with: + name: release-github + path: ./release-github/* + + macos: + runs-on: macos-latest + steps: + - uses: actions/checkout@v1 + - run: brew unlink node@12 + - run: brew install node + - run: ./ci/steps/release.sh + env: + # Otherwise we get a rate limited when fetching the ripgrep binary. + GITHUB_TOKEN: ${{ secrets.github_token }} + - name: Upload release artifacts + uses: actions/upload-artifact@v2 with: name: release-github path: ./release-github/* diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 7e6b2e2b..00000000 --- a/.travis.yml +++ /dev/null @@ -1,80 +0,0 @@ -language: node_js -node_js: node - -jobs: - include: - - name: Test - if: tag IS blank - script: ./ci/steps/test.sh - deploy: null - install: null - - name: Linux Release - if: tag IS present - script: ./ci/steps/linux-release.sh - install: null - # Unfortunately ARM on travis is very unreliable. - # We see random build failures, logging output being truncated, build being killed - # due to no output even though we use travis_wait etc. - # So we've disabled it for now. - # - name: Linux Release - # if: tag IS present - # arch: arm64 - # script: | - # sudo apt-get update && sudo apt-get install -y jq || exit 1 - # travis_wait 60 ./ci/steps/linux-release.sh - # install: null - - name: MacOS Release - if: tag IS present - os: osx - # node 13/14 crashes in the build process for some reason. - node_js: 12 - script: | - HOMEBREW_NO_INSTALL_CLEANUP=1 HOMEBREW_NO_AUTO_UPDATE=1 brew install jq || exit 1 - travis_wait 60 ./ci/steps/static-release.sh || exit 1 - install: null - -before_deploy: - - echo "$JSON_KEY" | base64 --decode > ./ci/key.json - -deploy: - - provider: releases - edge: true - draft: true - overwrite: true - tag_name: $TRAVIS_TAG - target_commitish: $TRAVIS_COMMIT - name: $TRAVIS_TAG - file: - - release-github/*.tar.gz - - release-github/*.zip - - release-github/*.deb - - release-github/*.rpm - on: - tags: true - - provider: gcs - edge: true - bucket: "codesrv-ci.cdr.sh" - upload_dir: "releases" - key_file: ./ci/key.json - local_dir: ./release-gcp - on: - tags: true - # TODO: The gcs provider fails to install on arm64. - condition: $TRAVIS_CPU_ARCH == amd64 - - provider: script - edge: true - # We do not use the travis npm deploy integration as it does not allow us to - # deploy a subpath and and v2 which should, just errors out that the src does not exist - script: ./ci/steps/publish-npm.sh - on: - tags: true - condition: $TRAVIS_CPU_ARCH == amd64 && $TRAVIS_OS_NAME == linux - -cache: - timeout: 600 - yarn: true - directories: - - .cache - - out - - dist - - lib/vscode/.build/extensions diff --git a/ci/README.md b/ci/README.md index 5c1c1c2b..0c561742 100644 --- a/ci/README.md +++ b/ci/README.md @@ -68,15 +68,11 @@ This directory contains the container for CI. ## steps -This directory contains a few scripts used in CI. Just helps avoid clobbering .travis.yml. +This directory contains a few scripts used in CI. +Just helps avoid clobbering .travis.yml. - [./steps/test.sh](./steps/test.sh) - Runs `yarn ci` after ensuring VS Code is patched -- [./steps/static-release.sh](./steps/static-release.sh) +- [./steps/release.sh](./steps/release.sh) - Runs the full static build process for CI -- [./steps/linux-release.sh](./steps/linux-release.sh) - - Runs the full static build process for CI - - Packages the release into a .deb and .rpm - - Builds and pushes a docker release -- [./steps/publish-npm.sh](./steps/publish-npm.sh) - - Authenticates yarn and publishes the built package from `./release` + - Packages the release into a .deb and .rpm for linux diff --git a/ci/container/Dockerfile b/ci/container/Dockerfile index dcbdd6aa..e40fe9aa 100644 --- a/ci/container/Dockerfile +++ b/ci/container/Dockerfile @@ -1,30 +1,41 @@ -FROM centos:7 +FROM debian -RUN yum update -y && yum install -y \ - devtoolset-6 \ - gcc-c++ \ - xz \ - ccache \ - git \ - wget \ - openssl \ - libxkbfile-devel \ - libsecret-devel \ - libx11-devel \ - gettext +RUN apt-get update -RUN yum install -y epel-release && \ - yum install -y ShellCheck jq golang +# Needed for debian repositories added below. +RUN apt-get install -y curl gnupg +# Installs node. +RUN curl -sL https://deb.nodesource.com/setup_14.x | bash - && \ + apt-get install -y nodejs + +# Installs yarn. +RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \ + echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \ + apt-get update && apt-get install -y yarn + +# Installs VS Code build deps. +RUN apt-get install -y build-essential \ + libsecret-1-dev \ + libx11-dev \ + libxkbfile-dev + +# Installs envsubst. +RUN apt-get install -y gettext-base + +# Misc build dependencies. +RUN apt-get install -y jq git rsync + +# Installs shellcheck. +RUN curl -L https://github.com/koalaman/shellcheck/releases/download/v0.7.1/shellcheck-v0.7.1.linux.$(uname -m).tar.xz | \ + tar -xJ && \ + mv shellcheck*/shellcheck /usr/local/bin && \ + rm -R shellcheck* + +# Install Go dependencies +RUN ARCH="$(dpkg --print-architecture)" && \ + curl "https://dl.google.com/go/go1.14.2.linux-$ARCH.tar.gz" | tar -C /usr/local -xz +ENV PATH=/usr/local/go/bin:/root/go/bin:$PATH +ENV GO111MODULE=on +RUN go get mvdan.cc/sh/v3/cmd/shfmt RUN go get github.com/goreleaser/nfpm/cmd/nfpm -ENV PATH=$PATH:/root/go/bin - -RUN mkdir /usr/share/node && cd /usr/share/node \ - && curl "https://nodejs.org/dist/v12.16.3/node-v12.16.3-linux-$(uname -m | sed 's/86_//; s/aarch/arm/').tar.xz" | tar xJ --strip-components=1 -- -ENV PATH "$PATH:/usr/share/node/bin" -RUN npm install -g yarn@1.22.4 - -RUN curl -L "https://github.com/mvdan/sh/releases/download/v3.0.1/shfmt_v3.0.1_linux_$(uname -m | sed 's/x86_/amd/; s/aarch64/arm/')" > /usr/local/bin/shfmt \ - && chmod +x /usr/local/bin/shfmt - -ENTRYPOINT ["/bin/bash", "-c"] diff --git a/ci/container/exec.sh b/ci/container/exec.sh deleted file mode 100755 index 57627b06..00000000 --- a/ci/container/exec.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail - -main() { - cd "$(dirname "$0")/../.." - - docker build ci/container - imageTag="$(docker build -q ci/container)" - docker run \ - --rm \ - -e CI \ - -e GITHUB_TOKEN \ - -e TRAVIS_TAG \ - -e NPM_TOKEN \ - -v "$(yarn cache dir):/usr/local/share/.cache/yarn/v6" \ - $(if [[ -f ~/.npmrc ]]; then echo -v "$HOME/.npmrc:/root/.npmrc"; fi) \ - -v "$PWD:/repo" \ - -w /repo \ - $(if [[ -t 0 ]]; then echo -it; fi) \ - "$imageTag" \ - "$*" -} - -main "$@" diff --git a/ci/dev/vscode.patch b/ci/dev/vscode.patch index 0f1302ff..e967b3b2 100644 --- a/ci/dev/vscode.patch +++ b/ci/dev/vscode.patch @@ -48,6 +48,22 @@ index 7a2320d828..5768890636 100644 +// yarnInstall('test/smoke'); // node modules required for smoketest +// yarnInstall('test/integration/browser'); // node modules required for integration yarnInstallBuildDependencies(); // node modules for watching, specific to host node version, not electron +diff --git a/build/npm/preinstall.js b/build/npm/preinstall.js +index cb88d37ade..6b3253af0a 100644 +--- a/build/npm/preinstall.js ++++ b/build/npm/preinstall.js +@@ -8,8 +8,9 @@ let err = false; + const majorNodeVersion = parseInt(/^(\d+)\./.exec(process.versions.node)[1]); + + if (majorNodeVersion < 10 || majorNodeVersion >= 13) { +- console.error('\033[1;31m*** Please use node >=10 and <=12.\033[0;0m'); +- err = true; ++ // We are ok building above Node 12. ++ // console.error('\033[1;31m*** Please use node >=10 and <=12.\033[0;0m'); ++ // err = true; + } + + const cp = require('child_process'); diff --git a/coder.js b/coder.js new file mode 100644 index 0000000000..0170b47241 diff --git a/ci/release-container/Dockerfile b/ci/release-container/Dockerfile index 0a99242f..cafcea28 100644 --- a/ci/release-container/Dockerfile +++ b/ci/release-container/Dockerfile @@ -27,11 +27,8 @@ ENV SHELL=/bin/bash RUN adduser --gecos '' --disabled-password coder && \ echo "coder ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/nopasswd -SHELL ["/bin/bash", "-c"] - -COPY ci/lib.sh /tmp/lib.sh -RUN source /tmp/lib.sh && rm /tmp/lib.sh && \ - curl -L "https://github.com/boxboat/fixuid/releases/download/v0.4.1/fixuid-0.4.1-linux-$(arch).tar.gz" | tar -C /usr/local/bin -xzf - && \ +RUN ARCH="$(dpkg --print-architecture)" && \ + curl -L "https://github.com/boxboat/fixuid/releases/download/v0.4.1/fixuid-0.4.1-linux-$ARCH.tar.gz" | tar -C /usr/local/bin -xzf - && \ chown root:root /usr/local/bin/fixuid && \ chmod 4755 /usr/local/bin/fixuid && \ mkdir -p /etc/fixuid && \ diff --git a/ci/steps/linux-release.sh b/ci/steps/linux-release.sh deleted file mode 100755 index 2d5b34d0..00000000 --- a/ci/steps/linux-release.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail - -main() { - cd "$(dirname "$0")/../.." - source ./ci/lib.sh - - ./ci/container/exec.sh ./ci/steps/static-release.sh - ./ci/container/exec.sh yarn pkg - ./ci/release-container/push.sh -} - -main "$@" diff --git a/ci/steps/publish-npm.sh b/ci/steps/publish-npm.sh deleted file mode 100755 index c4bcb967..00000000 --- a/ci/steps/publish-npm.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail - -main() { - cd "$(dirname "$0")/../.." - - echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc - ./ci/container/exec.sh yarn publish --non-interactive release -} - -main "$@" diff --git a/ci/steps/static-release.sh b/ci/steps/release.sh similarity index 81% rename from ci/steps/static-release.sh rename to ci/steps/release.sh index c0a70431..b8ac7202 100755 --- a/ci/steps/static-release.sh +++ b/ci/steps/release.sh @@ -11,6 +11,10 @@ main() { STATIC=1 yarn release ./ci/build/test-static-release.sh ./ci/build/archive-static-release.sh + + if [[ $OSTYPE == linux* ]]; then + yarn pkg + fi } main "$@"