DEV Community

Discussion on: CI with GitHub Actions for Ember Apps

Collapse
 
dknutsen profile image
Dan Knutsen • Edited

First off I want to say thanks a lot for writing this, it was tremendously helpful when I was setting up github actions for the first time recently.

A couple things I tried in addition to what you described which I thought might be worth sharing:

Cache action v2

There's a new version of the cache action which seems easier to use:

            - name: Cache yarn stuff
              uses: actions/cache@v2
              with:
                path: '**/node_modules'
                key: ci-modules-${{ hashFiles('**/yarn.lock') }}
            - name: Install dependencies
              run: yarn install --frozen-lockfile --non-interactive

Cache ember build

I wanted to cache the built ember app so it didn't need to be rebuilt for each testing job, so I added a "build" job:

    build:
        name: Download and cache dependencies and pre-build app
        runs-on: ${{ matrix.os }}
        strategy:
            matrix:
                os: [ubuntu-latest]
                node-version: [12.x] 
        steps:
            - name: Check out a copy of the repo
              uses: actions/checkout@v2
            - name: Use Node.js ${{ matrix.node-version }}
              uses: actions/setup-node@v1
              with:
                node-version: ${{ matrix.node-version }}
            - name: Cache yarn stuff
              uses: actions/cache@v2
              with:
                path: '**/node_modules'
                key: ci-modules-${{ hashFiles('**/yarn.lock') }}
            - name: Install dependencies
              run: yarn install --frozen-lockfile --non-interactive
            - name: Build ember app
              env:
                BROCCOLI_ENV: [development|test|production]
              run: yarn ember build
            - name: Upload built ember app
              uses: actions/upload-artifact@v1
              with:
                name: dist
                path: dist

which uploads the contents of dist as an "artifact" and then the 4 test partition jobs (which all depend on this job) download it and then run ember exam with the --path arg:

    test-partition-1:
        name: Run tests - Partition 1
        needs: [build]
        runs-on: ${{ matrix.os }}
        strategy:
            matrix:
                os: [ubuntu-latest]
                node-version: [12.x]
        steps:
            - name: Check out a copy of the repo
              uses: actions/checkout@v2 
            - name: Use Node.js ${{ matrix.node-version }}
              uses: actions/setup-node@v1
              with:
                node-version: ${{ matrix.node-version }}
            - name: Cache yarn stuff
              uses: actions/cache@v2
              with:
                path: '**/node_modules'
                key: ci-modules-${{ hashFiles('**/yarn.lock') }}
            - name: Install dependencies
              run: yarn install --frozen-lockfile --non-interactive

            - name: Download built ember app
              uses: actions/download-artifact@v1
              with:
                name: dist
                path: dist
            - name: Test partition 1
              run: yarn test --partition=1 --path=dist
Collapse
 
ijlee2 profile image
Isaac Lee • Edited

Sweet, I'll have to try out the caching of the build!

Yep, the actions that GitHub provides have changed since the blog was written, so I recommend readers to always check what the latest version does. You can find an example of what I did with actions/cache@v2 in ember-container-query.

I don't think I'll update this particular blog post to use v2 (to preserve what had happened in early 2020).

I do want to submit a workflow and a new, short blog post for dev.to GitHub Actions Hackathon, to show that it's easy to write a shareable GitHub Actions workflow for the Ember community. Is it okay if I include your build code into the workflow?

Collapse
 
dknutsen profile image
Dan Knutsen

Absolutely! Use it wherever you want. That's why I figured I'd share it 😁

Collapse
 
ijlee2 profile image
Isaac Lee • Edited

Thanks again for letting us know about pre-building the Ember app!

I was able to update the workflows for production apps. The workflows seem to now incur two-thirds of the billable time before. ✨

I will definitely write a follow-up blog post to explain pre-building the app as well as a couple of other tips.

Collapse
 
dknutsen profile image
Dan Knutsen

Wow that's great! It definitely seemed to be taking a while in my test app so I thought it would be a good step to try and shave off some time