From eb3cf303ad09c9c4ee740d4ee9b272d792c8ff8c Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Mon, 17 Feb 2020 23:22:12 -0500 Subject: [PATCH] Add back travis since github actions is trash --- .github/workflows/code.yml | 66 -------------------- .github/workflows/release.yml | 113 ---------------------------------- .travis.yml | 46 ++++++++++++++ ci/build.ts | 3 - ci/image/Dockerfile | 10 +-- ci/image/entrypoint.sh | 5 -- ci/image/run.sh | 11 ++++ ci/release.sh | 9 +-- 8 files changed, 62 insertions(+), 201 deletions(-) delete mode 100644 .github/workflows/code.yml delete mode 100644 .github/workflows/release.yml create mode 100644 .travis.yml delete mode 100755 ci/image/entrypoint.sh create mode 100755 ci/image/run.sh diff --git a/.github/workflows/code.yml b/.github/workflows/code.yml deleted file mode 100644 index a04ee7f1..00000000 --- a/.github/workflows/code.yml +++ /dev/null @@ -1,66 +0,0 @@ -name: code -on: [push, pull_request] - -env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - -jobs: - fmt: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v1 - - - name: Get yarn cache directory path - id: yarn-cache-dir-path - run: echo "::set-output name=dir::$(yarn cache dir)" - - uses: actions/cache@v1 - with: - path: ${{ steps.yarn-cache-dir-path.outputs.dir }} - key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} - restore-keys: | - ${{ runner.os }}-yarn- - - - name: Run yarn fmt - uses: ./ci/image - with: - args: yarn && yarn vscode && yarn fmt - - lint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v1 - - - name: Get yarn cache directory path - id: yarn-cache-dir-path - run: echo "::set-output name=dir::$(yarn cache dir)" - - uses: actions/cache@v1 - with: - path: ${{ steps.yarn-cache-dir-path.outputs.dir }} - key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} - restore-keys: | - ${{ runner.os }}-yarn- - - - name: Run yarn lint - uses: ./ci/image - with: - args: yarn && yarn vscode && yarn lint - - test: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v1 - - - name: Get yarn cache directory path - id: yarn-cache-dir-path - run: echo "::set-output name=dir::$(yarn cache dir)" - - uses: actions/cache@v1 - with: - path: ${{ steps.yarn-cache-dir-path.outputs.dir }} - key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} - restore-keys: | - ${{ runner.os }}-yarn- - - - name: Run yarn test - uses: ./ci/image - with: - args: yarn && yarn vscode && yarn test diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 5838dc40..00000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,113 +0,0 @@ -name: release -on: - push: -# tags: -# - 'v*' - -env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - -jobs: - linux-amd64: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v1 - - - name: Get yarn cache directory path - id: yarn-cache-dir-path - run: echo "::set-output name=dir::$(yarn cache dir)" - - uses: actions/cache@v1 - with: - path: ${{ steps.yarn-cache-dir-path.outputs.dir }} - key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} - restore-keys: | - ${{ runner.os }}-yarn- - - - name: Run release.sh - uses: ./ci/image - with: - args: yarn && yarn vscode && ./ci/release.sh - env: - PACKAGE: true - - name: Get release name - id: get-release-name - run: echo "::set-output name=name::$(cd release && ls *.tar.gz)" - - - name: Upload release as artifact - uses: actions/upload-artifact@master - with: - name: ${{ steps.get-release-name.outputs.name }} - path: release/${{ steps.get-release-name.outputs.name }} - - - name: Create Release - id: create-release - uses: actions/create-release@v1 - with: - tag_name: v2.1.0 - release_name: Release v2.1.0 - draft: true - - name: Upload release - id: upload-release-asset - uses: actions/upload-release-asset@v1 - with: - upload_url: ${{ steps.create-release.outputs.upload_url }} - asset_name: ${{ steps.get-release-name.outputs.name }} - asset_path: release/${{ steps.get-release-name.outputs.name }} - asset_content_type: application/gzip - - - name: Copy release into release image build context - uses: ./ci/image - with: - args: cp release/${{ steps.get-release-name.outputs.name }} ci/release-image - - name: Publish codercom/code-server docker container - uses: elgohr/Publish-Docker-Github-Action@master - with: - name: codercom/code-server - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - context: ci/release-image - tags: "anmol" - - macos: - runs-on: macos-latest - steps: - - uses: actions/checkout@v1 - - - name: Get yarn cache directory path - id: yarn-cache-dir-path - run: echo "::set-output name=dir::$(yarn cache dir)" - - uses: actions/cache@v1 - with: - path: ${{ steps.yarn-cache-dir-path.outputs.dir }} - key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} - restore-keys: | - ${{ runner.os }}-yarn- - - - name: Run release.sh - run: yarn && yarn vscode && ./ci/release.sh - env: - PACKAGE: true - - name: Get release name - id: get-release-name - run: echo "::set-output name=name::$(cd release && ls *.zip)" - - - name: Upload release as artifact - uses: actions/upload-artifact@master - with: - name: ${{ steps.get-release-name.outputs.name }} - path: release/${{ steps.get-release-name.outputs.name }} - - - name: Create Release - id: create-release - uses: actions/create-release@v1 - with: - tag_name: v2.1.0 - release_name: Release v2.1.0 - draft: true - - name: Upload release - uses: actions/upload-release-asset@v1 - with: - upload_url: ${{ steps.create-release.outputs.upload_url }} - asset_name: ${{ steps.get-release-name.outputs.name }} - asset_path: release/${{ steps.get-release-name.outputs.name }} - asset_content_type: application/zip diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..b67ccc62 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,46 @@ +language: minimal + +jobs: + include: + - stage: Code + name: Format + script: ./ci/image/run.sh "yarn && yarn vscode && yarn fmt" + - name: Lint + script: ./ci/image/run.sh "yarn && yarn vscode && yarn lint" + - name: Test + script: ./ci/image/run.sh "yarn && yarn vscode && yarn test" + + - stage: Release + name: Linux Release + script: travis_wait 60 ./ci/image/run.sh "yarn && yarn vscode && ci/release.sh" + - name: Linux ARM64 Release + script: travis_wait 60 ./ci/image/run.sh "yarn && yarn vscode && ci/release.sh" + arch: arm64 + - name: MacOS Release + os: osx + language: node_js + node_js: 12 + script: yarn && yarn vscode && travis_wait 60 ci/release.sh + +stages: + - name: Code + - name: Release + if: $TRAVIS_TAG != "" + +deploy: + - provider: releases + edge: true + draft: true + tag_name: $TRAVIS_TAG + target_commitish: $TRAVIS_COMMIT + name: $TRAVIS_TAG + file: + - release/*.tar.gz + - release/*.zip + on: + tags: true + condition: $TRAVIS_BUILD_STAGE_NAME == Release + +cache: + timeout: 600 + yarn: true diff --git a/ci/build.ts b/ci/build.ts index 47079161..f5cbbd68 100644 --- a/ci/build.ts +++ b/ci/build.ts @@ -248,9 +248,6 @@ class Builder { if (process.env.MINIFY) { await this.task(`restricting ${name} to production dependencies`, async () => { await util.promisify(cp.exec)("yarn --production --ignore-scripts", { cwd: buildPath }) - if (name === "code-server") { - await util.promisify(cp.exec)("yarn postinstall", { cwd: buildPath }) - } }) } } diff --git a/ci/image/Dockerfile b/ci/image/Dockerfile index 90e01eae..29496fc5 100644 --- a/ci/image/Dockerfile +++ b/ci/image/Dockerfile @@ -3,14 +3,8 @@ FROM node:12 RUN apt-get update && apt-get install -y \ libxkbfile-dev \ libx11-dev \ - libsecret-1-dev \ - dumb-init + libsecret-1-dev RUN curl -L https://github.com/mvdan/sh/releases/download/v3.0.1/shfmt_v3.0.1_linux_amd64 > /usr/local/bin/shfmt && chmod +x /usr/local/bin/shfmt -COPY entrypoint.sh /bin/entrypoint.sh - -ENV PAGER=cat -ENV CI=true - -ENTRYPOINT ["dumb-init", "/bin/entrypoint.sh"] +ENTRYPOINT ["/bin/bash", "-c"] diff --git a/ci/image/entrypoint.sh b/ci/image/entrypoint.sh deleted file mode 100755 index a8aa34c7..00000000 --- a/ci/image/entrypoint.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -eval "$@" diff --git a/ci/image/run.sh b/ci/image/run.sh new file mode 100755 index 00000000..3ac16e5a --- /dev/null +++ b/ci/image/run.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +set -euo pipefail + +main() { + cd "$(dirname "$0")/../.." + imageTag="$(docker build -q ci/image)" + docker run -t --rm -e CI -e GITHUB_TOKEN -v "$(yarn cache dir):/usr/local/share/.cache/yarn/v6" -v "$PWD:/repo" -w /repo "$imageTag" "$*" +} + +main "$@" diff --git a/ci/release.sh b/ci/release.sh index e84561b9..152e8861 100755 --- a/ci/release.sh +++ b/ci/release.sh @@ -7,17 +7,14 @@ set -euo pipefail function main() { cd "$(dirname "${0}")/.." - local code_server_version=${VERSION:-${TRAVIS_TAG:-${DRONE_TAG:-}}} + local code_server_version=${VERSION:-${TRAVIS_TAG:-}} if [[ -z $code_server_version ]]; then code_server_version=$(grep version ./package.json | head -1 | awk -F: '{ print $2 }' | sed 's/[",]//g' | tr -d '[:space:]') fi export VERSION=$code_server_version - YARN_CACHE_FOLDER="$(pwd)/yarn-cache" - export YARN_CACHE_FOLDER - - # Always minify and package on tags since that's when releases are pushed. - if [[ -n ${DRONE_TAG:-} || -n ${TRAVIS_TAG:-} ]]; then + # Always minify and package on CI since that's when releases are pushed. + if [[ ${CI:-} ]]; then export MINIFY="true" export PACKAGE="true" fi