Skip to content

new-release

new-release #240

Workflow file for this run

name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
repository_dispatch:
# Gets triggered by toitlang/toit whenever a release is created or edited.
types: [new-release]
jobs:
build:
# We're running on ubuntu-latest, nothing special
runs-on: ubuntu-latest
steps:
# As usual, we simply checkout the project
- name: Checkout
uses: actions/checkout@v3
# This action is provided by Cypress. It installs node and the NPM
# dependencies, and caches them.
- name: Cypress install
uses: cypress-io/github-action@v5
with:
# NOTE: we don't actually run tests here!
runTests: false
- name: Download latest releases
run: |
curl https://api.github.com/repos/toitlang/toit/releases > src/lib/releases.json
npm exec -- prettier -w src/lib/releases.json
# Now we run our lints. This is the place where you could run other tests
# unrelated to cypress (e.g.: unit tests).
- name: Run lints
run: npm run lint
# Now we're building the svelte site.
# This step generates a build/ directory.
- name: Build site
run: npm run build
# And lastly, we upload the generated build/ folder as artifact so we can
# use it in later steps.
- name: Upload build and .svelte-kit folder
uses: actions/upload-artifact@v3
with:
name: build
if-no-files-found: error
path: build
test:
# We depend on the build step for this.
needs: build
timeout-minutes: 15
runs-on: ubuntu-latest
# We need to use the cypress container here, that includes chrome and
# firefox.
container:
image: cypress/browsers:node14.17.0-chrome91-ff89
# This is necessary so Cypress can find Firefox.
options: --user 1001
# This whole block is really only for the Cypress dashboard. It enables
# parallel tests which only make sense if the dashboard is coordinating
# them.
#
# If you don't want to use the Cypress Dashboard, just delete the whole
# strategy section except the browser matrix.
#
# Read more about the parallelization here:
# https://docs.cypress.io/guides/guides/parallelization
strategy:
# When one test fails, DO NOT cancel the other containers, because this
# will kill Cypress processes leaving the Dashboard hanging ...
# https://github.com/cypress-io/github-action/issues/48
# fail-fast: false
matrix:
# Setting the different browsers we want to test. This is later used in
# the cypress action.
browser: [chrome, firefox]
# Run copies of the current job in parallel.
# containers: [1, 2]
steps:
- uses: actions/checkout@v3
# Download the build from the previous step.
- uses: actions/download-artifact@v3
with:
name: build
path: build
# Run all cypress tests.
- name: Cypress run
uses: cypress-io/github-action@v5
with:
# Simply start a python http server that exposes the build/ dir
start: python3 -m http.server --directory build 3000
# Only start tests when the server is up and running.
wait-on: http://localhost:3000/
# A simple python http server should really never take longer
# than 10 seconds to start.
wait-on-timeout: 10
browser: ${{ matrix.browser }}
# All these options are for the Cypress Dashboard.
# Remove them if you don't want to use it.
# record: true
# parallel: true
# group: 'UI - ${{ matrix.browser }}'
# Again, these environment variables are only necessary for the
# Cypress Dashboard.
env:
# CYPRESS_PROJECT_ID: ${{ secrets.CYPRESS_PROJECT_ID }}
# CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
# Recommended: pass the GitHub token lets this action correctly
# determine the unique run id necessary to re-run the checks
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
deploy:
# Only run if merged to main.
if: github.ref == 'refs/heads/main'
# Only deploy if all tests passed.
needs: [build, test]
runs-on: ubuntu-latest
steps:
# No need to checkout the project, since all we need is to download the
# build artifact from the build step.
- uses: actions/download-artifact@v3
with:
name: build
path: build
# This seems to be the simplest way to publish to a separate branch.
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_branch: gh-pages
publish_dir: ./build
# Optional. This will create a CNAME file so GitHub Pages serves it
# under this domain.
cname: toitlang.org