Skip to content
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

feat(ci): refactor build workflow #5572

Merged
merged 58 commits into from
Sep 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
93f6fd2
refactor: remove stylelint
jsjoeio Sep 17, 2022
f36c1f5
refactor: move shellcheck to separate job
jsjoeio Sep 17, 2022
3028e8e
refactor: add helm script and job
jsjoeio Sep 17, 2022
d8e0dc9
refactor: add eslint job and yarn script
jsjoeio Sep 17, 2022
0b1cfc9
fix(test/tsconfig): exclude test-plugin
jsjoeio Sep 17, 2022
fe70ebf
refactor: delete lint, add typecheck job
jsjoeio Sep 17, 2022
bbfbab4
refactor: remove prebuild
jsjoeio Sep 17, 2022
74330a1
wip: add notes about unit test refactor
jsjoeio Sep 17, 2022
a094400
refactor: delete buggy socket test
jsjoeio Sep 17, 2022
bc02005
refactor: move test-plugin to integration suite
jsjoeio Sep 17, 2022
64d234e
wip
jsjoeio Sep 17, 2022
13286bf
wip: refactor vscode integration tests
jsjoeio Sep 18, 2022
6c87b54
refactor: move unit tests to separate job
jsjoeio Sep 18, 2022
42bafc3
fix: formatting
jsjoeio Sep 18, 2022
917d92e
Revert "wip: refactor vscode integration tests"
jsjoeio Sep 19, 2022
6ad5d9a
Revert "refactor: move unit tests to separate job"
jsjoeio Sep 19, 2022
9030873
feat: collect codecov integration tests
jsjoeio Sep 19, 2022
1243d19
fixup! feat: collect codecov integration tests
jsjoeio Sep 19, 2022
f339d0d
fixup! feat: collect codecov integration tests
jsjoeio Sep 19, 2022
614f047
fixup!: move helm step
jsjoeio Sep 19, 2022
f9b3bda
fixup!: update ids for caching
jsjoeio Sep 19, 2022
4527d46
trigger ci
jsjoeio Sep 19, 2022
6f7133b
trigger ci
jsjoeio Sep 19, 2022
08a7fdf
chore: clean up names in security.yaml
jsjoeio Sep 19, 2022
e41dc6a
fixup!: remove .tsx
jsjoeio Sep 20, 2022
65b74fc
fixup!: change to src/**"
jsjoeio Sep 20, 2022
72d69b6
fixup!: move helm cmd to yaml
jsjoeio Sep 20, 2022
88119c2
fixup!: always build test plugin
jsjoeio Sep 20, 2022
f7dd9a6
fixup!: fix plugin typings
jsjoeio Sep 20, 2022
f9ecaaa
fixup! add back flakey test
jsjoeio Sep 20, 2022
ed1cd54
fixup!: only install helm deps if changes
jsjoeio Sep 20, 2022
d95a3b5
fixup!: revert node mod caching
jsjoeio Sep 20, 2022
7d5ad00
dont keep, test for asher
jsjoeio Sep 20, 2022
af37f1f
fixup!: add make to centos
jsjoeio Sep 20, 2022
eae094c
refactor: add test:native
jsjoeio Sep 21, 2022
02ed560
try updating glibc
jsjoeio Sep 21, 2022
9a1cd34
try 2.25
jsjoeio Sep 21, 2022
7d43eaa
Revert "refactor: move test-plugin to integration suite"
jsjoeio Sep 21, 2022
4c94137
Revert "try updating glibc"
jsjoeio Sep 21, 2022
5de48da
fixup!
jsjoeio Sep 21, 2022
77adf7b
asher: again
jsjoeio Sep 21, 2022
97842c4
try this for ts changes
jsjoeio Sep 21, 2022
6c8261a
fixup
jsjoeio Sep 21, 2022
c57dfe5
refactor: scripts.yml -> scripts.yaml
jsjoeio Sep 22, 2022
5a6d486
fixup!: move lint-sh to scripts.yaml
jsjoeio Sep 22, 2022
33163e8
fixup!: use apk for lint scripts
jsjoeio Sep 22, 2022
76168c9
fixup! fixup!: use apk for lint scripts
jsjoeio Sep 22, 2022
91fdc7e
fixup!: remove typecheck step
jsjoeio Sep 22, 2022
1ed536b
fix: pattern for lint ts files
jsjoeio Sep 22, 2022
158c64d
test: lint should fail
jsjoeio Sep 22, 2022
3b9e677
fixup! fixup!: use apk for lint scripts
jsjoeio Sep 22, 2022
27312a5
Revert "test: lint should fail"
jsjoeio Sep 22, 2022
eb2b181
fixup!: skip cancel workflow on forks
jsjoeio Sep 22, 2022
3c15bf1
fixup: remove cancel-workflow
jsjoeio Sep 22, 2022
185d259
fixup! fixup! fixup!: use apk for lint scripts
jsjoeio Sep 22, 2022
bfb6c01
fixup! fixup! fixup!: use apk for lint scripts
jsjoeio Sep 22, 2022
24776df
fixup!: fix yarn key
jsjoeio Sep 22, 2022
5f8beae
fixup!: add fetch-depth 0
jsjoeio Sep 22, 2022
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
99 changes: 84 additions & 15 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ concurrency:
# will skip running `yarn install` if it successfully fetched from cache

jobs:
prebuild:
name: Pre-build checks
fmt:
name: Format with Prettier
runs-on: ubuntu-latest
timeout-minutes: 20
timeout-minutes: 5
steps:
- name: Checkout repo
uses: actions/checkout@v3
Expand All @@ -35,15 +35,81 @@ jobs:
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: Install dependencies
code-asher marked this conversation as resolved.
Show resolved Hide resolved
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: SKIP_SUBMODULE_DEPS=1 yarn --frozen-lockfile

- name: Format files with Prettier
run: yarn fmt

lint-helm:
name: Lint Helm chart
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout repo
uses: actions/checkout@v3
with:
fetch-depth: 2

- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v23.2
with:
files: |
ci/helm-chart/**

- name: Install helm
jsjoeio marked this conversation as resolved.
Show resolved Hide resolved
if: steps.changed-files.outputs.any_changed == 'true'
uses: azure/setup-helm@v3.3
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: Install helm kubeval plugin
if: steps.changed-files.outputs.any_changed == 'true'
run: helm plugin install https://github.com/instrumenta/helm-kubeval

- name: Lint Helm chart
if: steps.changed-files.outputs.any_changed == 'true'
run: helm kubeval ci/helm-chart

lint-ts:
name: Lint TypeScript files
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout repo
uses: actions/checkout@v3
with:
fetch-depth: 2

- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v23.2
with:
files: |
**/*.ts
**/*.js
files_ignore: |
lib/vscode/**

- name: Install Node.js v16
if: steps.changed-files.outputs.any_changed == 'true'
uses: actions/setup-node@v3
with:
node-version: "16"

- name: Fetch dependencies from cache
if: steps.changed-files.outputs.any_changed == 'true'
id: cache-node-modules
uses: actions/cache@v3
with:
Expand All @@ -53,20 +119,15 @@ jobs:
yarn-build-

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

- name: Run yarn fmt
run: yarn fmt
if: success()

- name: Run yarn lint
run: yarn lint
if: success()
- name: Lint TypeScript files
if: steps.changed-files.outputs.any_changed == 'true'
run: yarn lint:ts

build:
name: Build
needs: prebuild
runs-on: ubuntu-latest
timeout-minutes: 30
env:
Expand Down Expand Up @@ -222,6 +283,8 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 15
container: "centos:7"
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

steps:
- name: Checkout repo
Expand All @@ -234,7 +297,7 @@ jobs:

- name: Install development tools
run: |
yum install -y epel-release centos-release-scl
yum install -y epel-release centos-release-scl make
yum install -y devtoolset-9-{make,gcc,gcc-c++} jq rsync python3

- name: Install nfpm and envsubst
Expand Down Expand Up @@ -278,6 +341,12 @@ jobs:
- name: Run integration tests on standalone release
run: yarn test:integration

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

- name: Build packages with nfpm
run: yarn package

Expand Down Expand Up @@ -417,8 +486,8 @@ jobs:
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: SKIP_SUBMODULE_DEPS=1 yarn install

- name: Run integration tests on standalone release
run: yarn test:integration
- name: Run native module tests on standalone release
run: yarn test:native
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the rename.


- name: Build packages with nfpm
run: yarn package
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,17 @@ jobs:

- name: Run script unit tests
run: ./ci/dev/test-scripts.sh

lint:
name: Lint shell files
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout repo
uses: actions/checkout@v3

- name: Install lint utilities
run: sudo apt install shellcheck

- name: Lint shell files
run: ./ci/dev/lint-scripts.sh
7 changes: 4 additions & 3 deletions .github/workflows/security.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "Security Scanning"
name: Security

on:
push:
Expand All @@ -19,7 +19,7 @@ concurrency:

jobs:
audit-ci:
name: Run audit-ci
name: Audit node modules
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
Expand Down Expand Up @@ -51,6 +51,7 @@ jobs:
if: success()

trivy-scan-repo:
name: Scan repo with Trivy
permissions:
contents: read # for actions/checkout to fetch code
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
Expand Down Expand Up @@ -82,7 +83,7 @@ jobs:
actions: read # for github/codeql-action/init to get workflow details
contents: read # for actions/checkout to fetch code
security-events: write # for github/codeql-action/autobuild to send a status report
name: Analyze
name: Analyze with CodeQL
runs-on: ubuntu-20.04

steps:
Expand Down
2 changes: 0 additions & 2 deletions .stylelintrc.yaml

This file was deleted.

9 changes: 9 additions & 0 deletions ci/dev/lint-scripts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash
set -euo pipefail

main() {
cd "$(dirname "$0")/../.."
shellcheck -e SC2046,SC2164,SC2154,SC1091,SC1090,SC2002 $(git ls-files '*.sh' | grep -v 'lib/vscode')
}

main "$@"
18 changes: 0 additions & 18 deletions ci/dev/lint.sh

This file was deleted.

39 changes: 39 additions & 0 deletions ci/dev/test-native.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env bash
set -euo pipefail

help() {
echo >&2 " You can build the standalone release with 'yarn release:standalone'"
echo >&2 " Or you can pass in a custom path."
echo >&2 " CODE_SERVER_PATH='/var/tmp/coder/code-server/bin/code-server' yarn test:integration"
}

# Make sure a code-server release works. You can pass in the path otherwise it
# will look for release-standalone in the current directory.
#
# This is to make sure we don't have Node version errors or any other
# compilation-related errors.
main() {
cd "$(dirname "$0")/../.."

source ./ci/lib.sh

local path="$RELEASE_PATH-standalone/bin/code-server"
if [[ ! ${CODE_SERVER_PATH-} ]]; then
echo "Set CODE_SERVER_PATH to test another build of code-server"
else
path="$CODE_SERVER_PATH"
fi

echo "Running tests with code-server binary: '$path'"

if [[ ! -f $path ]]; then
echo >&2 "No code-server build detected"
echo >&2 "Looked in $path"
help
exit 1
fi

CODE_SERVER_PATH="$path" ./test/node_modules/.bin/jest "$@" --coverage=false --testRegex "./test/integration/help.test.ts"
}

main "$@"
9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,16 @@
"test:e2e:proxy": "USE_PROXY=1 ./ci/dev/test-e2e.sh",
"test:unit": "./ci/dev/test-unit.sh --forceExit --detectOpenHandles",
"test:integration": "./ci/dev/test-integration.sh",
"test:native": "./ci/dev/test-native.sh",
"test:scripts": "./ci/dev/test-scripts.sh",
"package": "./ci/build/build-packages.sh",
"postinstall": "./ci/dev/postinstall.sh",
"publish:npm": "./ci/steps/publish-npm.sh",
"publish:docker": "./ci/steps/docker-buildx-push.sh",
"_audit": "./ci/dev/audit.sh",
"fmt": "./ci/dev/fmt.sh",
"lint": "./ci/dev/lint.sh",
"lint:scripts": "./ci/dev/lint-scripts.sh",
"lint:ts": "eslint --max-warnings=0 --fix $(git ls-files '*.ts' '*.js' | grep -v 'lib/vscode')",
"test": "echo 'Run yarn test:unit or yarn test:e2e' && exit 1",
"ci": "./ci/dev/ci.sh",
"watch": "VSCODE_DEV=1 VSCODE_IPC_HOOK_CLI= NODE_OPTIONS='--max_old_space_size=32384 --trace-warnings' ts-node ./ci/dev/watch.ts",
Expand All @@ -53,15 +55,12 @@
"audit-ci": "^6.0.0",
"doctoc": "^2.0.0",
"eslint": "^7.7.0",
"eslint-config-prettier": "^8.1.0",
"eslint-config-prettier": "^8.5.0",
"eslint-import-resolver-typescript": "^2.5.0",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-prettier": "^4.0.0",
"prettier": "^2.2.1",
"prettier-plugin-sh": "^0.12.0",
"shellcheck": "^1.0.0",
"stylelint": "^13.0.0",
"stylelint-config-recommended": "^5.0.0",
"ts-node": "^10.0.0",
"typescript": "^4.6.2"
},
Expand Down
3 changes: 2 additions & 1 deletion test/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"extends": "../tsconfig.json",
"include": ["./**/*.ts"]
"include": ["./**/*.ts"],
"exclude": ["./unit/node/test-plugin"]
}
2 changes: 2 additions & 0 deletions test/unit/node/routes/vscode.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { clean, tmpdir } from "../../../utils/helpers"
import * as httpserver from "../../../utils/httpserver"
import * as integration from "../../../utils/integration"

// TODO@jsjoeio - move these to integration tests since they rely on Code
// to be built
describe("vscode", () => {
let codeServer: httpserver.HttpServer | undefined

Expand Down
Loading