diff --git a/.github/workflows/ci.yml b/.github/workflows/build.yml similarity index 61% rename from .github/workflows/ci.yml rename to .github/workflows/build.yml index 32d14bf..ff956b1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/build.yml @@ -1,35 +1,19 @@ -name: CI - +name: Generate build for reuse on: - push: - branches: - - '**' - paths-ignore: - - 'server/**' - pull_request: - branches: - - '**' - paths-ignore: - - 'server/**' + workflow_call: jobs: - build-and-test: + build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 - - - name: Retrieve vscode icons - uses: actions/checkout@v2 - with: - repository: 'vscode-icons/vscode-icons' - path: 'vscode-icons' + - uses: actions/checkout@v3 - name: Get yarn cache directory path id: yarn-cache-dir-path run: echo "::set-output name=dir::$(yarn cache dir)" - - name: Cache Dependencies + - name: Cache deps uses: actions/cache@v1 id: yarn-cache with: @@ -44,17 +28,19 @@ jobs: run: | yarn + - name: Retrieve vscode icons + uses: actions/checkout@v3 + with: + repository: 'vscode-icons/vscode-icons' + path: 'vscode-icons' + - name: Build run: | make build - - name: Unit Test - run: | - yarn jest src - - - name: E2E Test - uses: mujo-code/puppeteer-headful@master - env: - CI: 'true' + - name: Archive production artifacts + uses: actions/upload-artifact@v3 with: - args: yarn test + name: dist + path: | + dist diff --git a/.github/workflows/release-assets.yml b/.github/workflows/release-assets.yml index 155f623..c0fe524 100644 --- a/.github/workflows/release-assets.yml +++ b/.github/workflows/release-assets.yml @@ -7,39 +7,23 @@ on: - release-* jobs: + build: + uses: ./.github/workflows/build.yml + release: + needs: build runs-on: ubuntu-latest steps: - - name: Get the ref - id: get_ref - run: echo ::set-output name=VERSION::$(echo $GITHUB_REF | cut -d / -f 3) + - uses: actions/checkout@v3 - - uses: actions/checkout@v1 - - - name: Get yarn cache directory path - id: yarn-cache-dir-path - run: echo "::set-output name=dir::$(yarn cache dir)" - - - name: Cache deps - uses: actions/cache@v1 - id: yarn-cache + - name: Download a built dist artifact + uses: actions/download-artifact@v3 with: - path: ${{ steps.yarn-cache-dir-path.outputs.dir }} - key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} - restore-keys: | - ${{ runner.os }}-yarn- + name: dist - - name: Retrieve vscode icons - uses: actions/checkout@v2 - with: - repository: 'vscode-icons/vscode-icons' - path: 'vscode-icons' - - - name: Build - run: | - yarn - make build + - uses: ./.github/workflows/version.yml + id: version - name: Create Release id: create_release @@ -47,8 +31,8 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - tag_name: ${{ steps.get_ref.outputs.VERSION }} - release_name: ${{ steps.get_ref.outputs.VERSION }} + tag_name: ${{ steps.version.outputs.VERSION }} + release_name: ${{ steps.version.outputs.VERSION }} draft: false prerelease: false diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..c9b72b1 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,95 @@ +name: Tests + +on: + push: + branches: + - '**' + paths-ignore: + - 'server/**' + pull_request: + branches: + - '**' + paths-ignore: + - 'server/**' + # Runs everyday to detect GitHub update in time + schedule: + - cron: '0 0 * * *' + +jobs: + build: + uses: ./.github/workflows/build.yml + + e2e-test: + needs: build + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Download a built dist artifact + uses: actions/download-artifact@v3 + with: + name: dist + + # Found no way to reuse cache steps + - name: Get yarn cache directory path + id: yarn-cache-dir-path + run: echo "::set-output name=dir::$(yarn cache dir)" + + - name: Cache deps + uses: actions/cache@v1 + id: yarn-cache + with: + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- + + - name: Install Dependencies + env: + PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true + run: | + yarn + + - name: E2E Test + uses: mujo-code/puppeteer-headful@master + env: + CI: 'true' + with: + args: yarn test + + unit-test: + needs: build + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Download a built dist artifact + uses: actions/download-artifact@v3 + with: + name: dist + + # Found no way to reuse cache steps + - name: Get yarn cache directory path + id: yarn-cache-dir-path + run: echo "::set-output name=dir::$(yarn cache dir)" + + - name: Cache deps + uses: actions/cache@v1 + id: yarn-cache + with: + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- + + - name: Install Dependencies + env: + PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true + run: | + yarn + + - name: Unit Test + run: | + yarn jest src diff --git a/.github/workflows/version.yml b/.github/workflows/version.yml new file mode 100644 index 0000000..793a37a --- /dev/null +++ b/.github/workflows/version.yml @@ -0,0 +1,19 @@ +name: Get VERSION for referencing +on: + workflow_call: + outputs: + VERSION: + description: "The VERSION string" + value: ${{ jobs.build.outputs.VERSION }} + +jobs: + get-version: + runs-on: ubuntu-latest + + outputs: + VERSION: ${{ steps.get_ref.outputs.VERSION }} + + steps: + - name: Get the ref + id: get_ref + run: echo ::set-output name=VERSION::$(echo $GITHUB_REF | cut -d / -f 3)