Skip to content

Commit

Permalink
Refactor Main Workflow and Fix failing instalation on Linux (#602)
Browse files Browse the repository at this point in the history
* Update workflow.yaml to include new jobs for checks, unit tests, build, and integration test

* Update workflow.yaml

* Update workflow.yaml to use relative path in the 'uses' field for the 'Run Integration Tests' job

* Update workflow.yaml to use relative path for the 'Upload Artifact' job

* Update workflow.yaml to rename the 'Run' job to 'Integration Tests'

* Update and pin dependencies in workflow.yaml

* Update workflow.yaml to include 'fail-fast: false' in the strategy matrix

* Add Graphviz test to workflow.yaml

* Add apt-get clean command before apt-get update and refactor unit tests

* Refactor GraphvizInstaller to remove duplicate code and improve code readability

* Refactor GraphvizInstaller

* Fix format
  • Loading branch information
kamiazya authored Apr 24, 2024
1 parent d1cba3a commit d873750
Show file tree
Hide file tree
Showing 6 changed files with 228 additions and 98 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ jobs:
name: Release GitHub Actions
runs-on: ubuntu-latest
steps:
- uses: technote-space/release-github-actions@v8
- uses: technote-space/release-github-actions@052f205daf62dff0c3ece009f07b38f3ec83e01a # v8.0.3
4 changes: 2 additions & 2 deletions .github/workflows/update-license-year.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ jobs:
update-license-year:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4.1.3
with:
fetch-depth: 0
- uses: FantasticFiasco/action-update-license-year@v3
- uses: FantasticFiasco/action-update-license-year@9135da8f9ccc675217e02357c744b6b541d45cb0 # v3.0.2
with:
token: ${{ secrets.GITHUB_TOKEN }}
84 changes: 73 additions & 11 deletions .github/workflows/workflow.yaml
Original file line number Diff line number Diff line change
@@ -1,26 +1,88 @@
name: Main workflow
on: [push]
jobs:
run:
name: Run
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
check:
name: Checks
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4.1.3
- name: Set Node.js 20.x
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: 20.x
cache: yarn
- name: Install Dependencies
run: yarn install --frozen-lockfile
- name: Lint
run: yarn lint
- name: TypeCheck
run: yarn typecheck

unit-test:
name: Unit Tests
runs-on: ubuntu-latest
needs: check
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4.1.3
- name: Set Node.js 20.x
uses: actions/setup-node@v4
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: 20.x
cache: yarn
- name: Install Dependencies
run: yarn install --frozen-lockfile
- if: matrix.os != 'windows-latest'
name: Lint
run: yarn lint
- name: Test
run: yarn test
- name: Build
run: yarn build

build:
name: Build
runs-on: ubuntu-latest
needs: check
steps:
- name: Checkout
uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4.1.3
- name: Set Node.js 20.x
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: 20.x
cache: yarn
- name: Install Dependencies
run: yarn install --frozen-lockfile
- name: Build
run: yarn build
- name: Upload Artifact
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
with:
name: lib
path: lib

integration-test:
name: Integration Tests
runs-on: ${{ matrix.os }}
needs:
- build
- unit-test
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- name: Checkout
uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4.1.3
- name: Set Node.js 20.x
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: 20.x
cache: yarn
- name: Install Dependencies
run: yarn install --frozen-lockfile
- name: Download Artifact
uses: actions/download-artifact@9c19ed7fe5d278cd354c7dfd5d3b88589c7e2395 # v4.1.6
- name: Run Integration Tests
uses: ./
- name: Graphviz test
run: dot -V
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"scripts": {
"lint": "biome check src",
"format": "biome check --apply src",
"typecheck": "tsc --noEmit",
"build": "tsc",
"test": "vitest"
},
Expand Down
8 changes: 8 additions & 0 deletions src/GraphvizInstaller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ export class GraphvizInstaller {
const graphvizVersion = getInput("ubuntu-graphviz-version");
const libgraphvizdevVersion = getInput("ubuntu-libgraphvizdev-version");
if (skipAptUpdate === false) {
await exec("sudo", ["apt-get", "clean"]);
// https://github.com/actions/runner-images/issues/9733#issuecomment-2074565599
await exec("sudo", [
"sudo",
"rm",
"/etc/apt/sources.list.d/microsoft-prod.list",
]);

await exec("sudo", ["apt-get", "update"]);
}
await exec("sudo", [
Expand Down
Loading

0 comments on commit d873750

Please sign in to comment.