Skip to content

testing #8

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

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open
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
208 changes: 1 addition & 207 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,6 @@ jobs:
id: vscode-rev
run: echo "::set-output name=rev::$(git rev-parse HEAD:./lib/vscode)"

- name: Get version
id: version
run: echo "::set-output name=version::$(jq -r .version package.json)"

# We need to rebuild when we have a new version of Code, when any of
# the patches changed, or when the code-server version changes (since
# it gets embedded into the code). Use VSCODE_CACHE_VERSION to
Expand All @@ -200,25 +196,12 @@ jobs:
uses: actions/cache@v3
with:
path: lib/vscode-reh-web-*
key: vscode-reh-package-${{ secrets.VSCODE_CACHE_VERSION }}-${{ steps.vscode-rev.outputs.rev }}-${{ steps.version.outputs.version }}-${{ hashFiles('patches/*.diff', 'ci/build/build-vscode.sh') }}
key: vscode-reh-package-${{ secrets.VSCODE_CACHE_VERSION }}-${{ steps.vscode-rev.outputs.rev }}-${{ hashFiles('patches/*.diff', 'ci/build/build-vscode.sh') }}

- name: Build vscode
if: steps.cache-vscode.outputs.cache-hit != 'true'
run: yarn build:vscode

# Our code imports code from VS Code's `out` directory meaning VS Code
# must be built before running these tests.
# TODO: Move to its own step?
- name: Run code-server unit tests
run: yarn test:unit
if: success()

- name: Upload coverage report to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
if: success()

# The release package does not contain any native modules
# and is neutral to architecture/os/libc version.
- name: Create release package
Expand All @@ -234,192 +217,3 @@ jobs:
with:
name: npm-package
path: ./package.tar.gz

npm:
name: Publish npm package
# the npm-package gets uploaded as an artifact in Build
# so we need that to complete before this runs
needs: build
# This environment "npm" requires someone from
# coder/code-server-reviewers to approve the PR before this job runs.
environment: npm
# Only run if PR comes from base repo or event is not a PR
# Reason: forks cannot access secrets and this will always fail
if: github.event.pull_request.head.repo.full_name == github.repository || github.event_name != 'pull_request'
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3

- name: Download artifact
uses: actions/download-artifact@v3
id: download
with:
name: "npm-package"
path: release-npm-package

- name: Run ./ci/steps/publish-npm.sh
run: yarn publish:npm
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
# NOTE@jsjoeio
# NPM_ENVIRONMENT intentionally not set here.
# Instead, itis determined in publish-npm.sh script
# using GITHUB environment variables

- name: Comment npm information
uses: marocchino/sticky-pull-request-comment@v2
with:
GITHUB_TOKEN: ${{ github.token }}
header: npm-dev-build
message: |
✨ code-server dev build published to npm for PR #${{ github.event.number }}!
* _Last publish status_: success
* _Commit_: ${{ github.event.pull_request.head.sha }}

To install in a local project, run:
```shell-session
npm install @coder/code-server-pr@${{ github.event.number }}
```

To install globally, run:
```shell-session
npm install -g @coder/code-server-pr@${{ github.event.number }}
```

test-e2e:
name: Run e2e tests
needs: build
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout repo
uses: actions/checkout@v3

- name: Install Node.js v16
uses: actions/setup-node@v3
with:
node-version: "16"

- name: Fetch dependencies from cache
id: cache-node-modules
uses: actions/cache@v3
with:
path: "**/node_modules"
key: yarn-build-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
yarn-build-

- name: Download npm package
uses: actions/download-artifact@v3
with:
name: npm-package

- name: Decompress npm package
run: tar -xzf package.tar.gz

- name: Install release package dependencies
run: cd release && yarn install

- name: Install dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: SKIP_SUBMODULE_DEPS=1 yarn --frozen-lockfile

- name: Install Playwright OS dependencies
run: |
./test/node_modules/.bin/playwright install-deps
./test/node_modules/.bin/playwright install

- name: Run end-to-end tests
run: CODE_SERVER_TEST_ENTRY=./release yarn test:e2e --global-timeout 840000

- name: Upload test artifacts
if: always()
uses: actions/upload-artifact@v3
with:
name: failed-test-videos
path: ./test/test-results

- name: Remove release packages and test artifacts
run: rm -rf ./release ./test/test-results

test-e2e-proxy:
name: Run e2e tests behind proxy
needs: build
runs-on: ubuntu-latest
timeout-minutes: 25
steps:
- name: Checkout repo
uses: actions/checkout@v3

- name: Install Node.js v16
uses: actions/setup-node@v3
with:
node-version: "16"

- name: Fetch dependencies from cache
id: cache-node-modules
uses: actions/cache@v3
with:
path: "**/node_modules"
key: yarn-build-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
yarn-build-

- name: Download npm package
uses: actions/download-artifact@v3
with:
name: npm-package

- name: Decompress npm package
run: tar -xzf package.tar.gz

- name: Install release package dependencies
run: cd release && yarn install

- name: Install dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: SKIP_SUBMODULE_DEPS=1 yarn --frozen-lockfile

- name: Install Playwright OS dependencies
run: |
./test/node_modules/.bin/playwright install-deps
./test/node_modules/.bin/playwright install

- name: Cache Caddy
uses: actions/cache@v2
id: caddy-cache
with:
path: |
~/.cache/caddy
key: cache-caddy-2.5.2

- name: Install Caddy
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: steps.caddy-cache.outputs.cache-hit != 'true'
run: |
gh release download v2.5.2 --repo caddyserver/caddy --pattern "caddy_2.5.2_linux_amd64.tar.gz"
mkdir -p ~/.cache/caddy
tar -xzf caddy_2.5.2_linux_amd64.tar.gz --directory ~/.cache/caddy

- name: Start Caddy
run: sudo ~/.cache/caddy/caddy start --config ./ci/Caddyfile

- name: Run end-to-end tests
run: CODE_SERVER_TEST_ENTRY=./release yarn test:e2e:proxy --global-timeout 840000

- name: Stop Caddy
if: always()
run: sudo ~/.cache/caddy/caddy stop --config ./ci/Caddyfile

- name: Upload test artifacts
if: always()
uses: actions/upload-artifact@v3
with:
name: failed-test-videos-proxy
path: ./test/test-results

- name: Remove release packages and test artifacts
run: rm -rf ./release ./test/test-results
52 changes: 34 additions & 18 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ on:
# Shows the manual trigger in GitHub UI
# helpful as a back-up in case the GitHub Actions Workflow fails
workflow_dispatch:
inputs:
version:
description: The version to publish (include "v", i.e. "v4.9.1").
type: string
required: true

release:
types: [released]
Expand All @@ -24,21 +29,23 @@ jobs:
- name: Checkout code-server
uses: actions/checkout@v3

- name: Get version
id: version
run: echo "::set-output name=version::$(jq -r .version package.json)"

- name: Download npm package from release artifacts
uses: robinraju/release-downloader@v1.5
with:
repository: "coder/code-server"
tag: v${{ steps.version.outputs.version }}
repository: "jsjoeio/code-server"
tag: ${{ github.event.inputs.version || github.ref_name }}
fileName: "package.tar.gz"
out-file-path: "release-npm-package"

- name: Get and set VERSION
run: |
TAG="${{ github.event.inputs.version || github.ref_name }}"
echo "VERSION=${TAG#v}" >> $GITHUB_ENV

- name: Publish npm package and tag with "latest"
run: yarn publish:npm
env:
VERSION: ${{ env.VERSION }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_ENVIRONMENT: "production"
Expand All @@ -62,9 +69,16 @@ jobs:
git config --global user.name cdrci
git config --global user.email opensource@coder.com

- name: Get and set VERSION
run: |
TAG="${{ github.event.inputs.version || github.ref_name }}"
echo "VERSION=${TAG#v}" >> $GITHUB_ENV

- name: Bump code-server homebrew version
env:
VERSION: ${{ env.VERSION }}
HOMEBREW_GITHUB_API_TOKEN: ${{secrets.HOMEBREW_GITHUB_API_TOKEN}}

run: ./ci/steps/brew-bump.sh

aur:
Expand All @@ -73,6 +87,8 @@ jobs:
timeout-minutes: 10
env:
GH_TOKEN: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }}
VERSION: ${{ github.event.inputs.version || github.ref_name }}

steps:
# We need to checkout code-server so we can get the version
- name: Checkout code-server
Expand All @@ -81,13 +97,6 @@ jobs:
fetch-depth: 0
path: "./code-server"

- name: Get code-server version
id: version
run: |
pushd code-server
echo "::set-output name=version::$(jq -r .version package.json)"
popd

- name: Checkout code-server-aur repo
uses: actions/checkout@v3
with:
Expand All @@ -106,10 +115,15 @@ jobs:
git config --global user.name cdrci
git config --global user.email opensource@coder.com

- name: Get and set VERSION
run: |
TAG="${{ github.event.inputs.version || github.ref_name }}"
echo "VERSION=${TAG#v}" >> $GITHUB_ENV

- name: Validate package
uses: hapakaien/archlinux-package-action@v2
with:
pkgver: ${{ steps.version.outputs.version }}
pkgver: ${{ env.VERSION }}
updpkgsums: true
srcinfo: true

Expand Down Expand Up @@ -147,19 +161,21 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Get version
id: version
run: echo "::set-output name=version::$(jq -r .version package.json)"
- name: Get and set VERSION
run: |
TAG="${{ github.event.inputs.version || github.ref_name }}"
echo "VERSION=${TAG#v}" >> $GITHUB_ENV

- name: Download release artifacts
uses: robinraju/release-downloader@v1.5
with:
repository: "coder/code-server"
tag: v${{ steps.version.outputs.version }}
tag: v${{ env.VERSION }}
fileName: "*.deb"
out-file-path: "release-packages"

- name: Publish to Docker
run: yarn publish:docker
env:
VERSION: ${{ steps.version.outputs.version }}
GITHUB_TOKEN: ${{ github.token }}
Loading