Migrating from CircleCI

Hey everyone,

I currently have a CircleCi config file that builds my code and runs my tests for the client and the api. I would really like to move over to Github actions to do all this but I’ve been having issues migrating over.

The services I currently use are

  • Postgres

  • Redis

  • Cypress 

I’ve looked at a bunch of exaples and read the docs but it seems more complex than I was hoping for. E.g The postgres example service  alone is over 70 lines of code when my original CI config is just 40.

Here is my CircleCi config, I would love to know how to achieve the same with Github Actions

version: 2
jobs:
  build:
    docker:
      - image: cypress/base:10
      - image: circleci/postgres:9.6.5-alpine-ram
        environment:
          POSTGRES_USER: root
          POSTGRES_DB: tunebase-test
      - image: redis

    working_directory: ~/tunebase

    steps:
      - checkout

      # Download and cache dependencies
      - restore_cache:
          name: Restore Yarn Package Cache
          keys:
            - v24-dependencies-{{ checksum "yarn.lock" }}
            # fallback to using the latest cache if no exact match is found
            - v24-dependencies-

      - run: yarn install --frozen-lockfile
      - run: yarn run bootstrap

      - save_cache:
          name: Save Yarn Package Cache
          paths:
            - ~/.cache
          key: v24-dependencies-{{ checksum "yarn.lock" }}

      # Make sure both api and www build
      - run: yarn run build

      # run client and api tests
      - run: yarn --cwd packages/api test
      - run: yarn --cwd packages/www test:ci

Thanks!

Hi @malimccalla ,

It should be like below:

name: version2
on: [push] # define the event to trigger the workflow

jobs:
  job1:
    defaults:
      run:
        working-directory: ~/tunebase #set the working directory for the job.
    services: #define 3 different services
      cypress:
        image: cypress/base:10
      postgres:
        image: circleci/postgres:9.6.5-alpine-ram
        env:
          POSTGRES_USER: root
          POSTGRES_PASSWORD: password
          POSTGRES_DB: tunebase-test
      redis:
        image: redis

    runs-on: ubuntu-latest
    steps:
      - name: checkout # use action to checkout the repo content
        uses: actions/checkout@v2
      - name: Restore Yarn Package Cache # restore & save cache
        uses: actions/cache@v1
        with:
          path: ~/.cache
          key: v24-dependencies-{{ checksum "yarn.lock" }}
          restore-keys: |
            v24-dependencies-{{ checksum "yarn.lock" }}
            v24-dependencies-
       - run: yarn install --frozen-lockfile
       - run: yarn run bootstrap

       # Make sure both api and www build
       - run: yarn run build

Please read below docs for more details:

1. https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idservices

2. https://help.github.com/en/actions/configuring-and-managing-workflows/caching-dependencies-to-speed-up-workflows

  1. Currently yaml archor is not supported in Github actions.

Thanks.

1 Like