Skip to content

Migrate from Travis to GitHub Action #228

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Test
on:
# Ensure GitHub actions are not run twice for same commits
push:
branches: [master]
tags: ['*']
pull_request:
types: [opened, synchronize, reopened]
Comment on lines +3 to +8
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on traffic mesh we are not seeing duplicated runs with just on: push: https://github.com/netlify/traffic-mesh/blob/master/.github/workflows/rust.yml#L3

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can confess that I copy&pasted from https://github.com/netlify/js-client/blob/1000eac0fdf9434336adefdde5cce1d46c02d60e/.github/workflows/workflow.yml#L2-L8 , any opinions/suggestions @ehmicky ? (as I copy pasted from you :P)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was suggested by @erezrokah and was originally copied from netlify-cms.
When doing only push, PRs that come from forked repositories do not seem to be included.
When doing both push and pull_request, PRs that come from non-forked repositories are run twice, which is the reason behind branches: [master]. The tags and types are just the default values (can be removed).

@erezrokah Please correct me if I'm wrong.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, that explains why i haven't seen it on a private repo 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice 🎉 very good to know, thanks for tips @ehmicky and @erezrokah , sounds like we could copypasta this whenever we migrate other open source repos too

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another thing to consider is that GitHub secrets are not passed to actions triggered from forked repositories.
We had to create a separate testing flow for the CMS project:
https://github.com/netlify/netlify-cms/blob/b5a242ec8ed627e7f5e2ce8af454dd1dda1f71cc/.github/workflows/nodejs.yml#L104

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good to know, thanks for sharing @erezrokah ! I think it won't be a problem with this repo but I'll keep it in my mind 👍


jobs:
test-node:
name: Node ${{ matrix.node_version }} on ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
node_version: [12]
runs-on: ${{ matrix.os }}
steps:
- name: Install Node.js ${{ matrix.node }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node_version }}
- name: Git checkout
uses: actions/checkout@v1
- name: Install dependencies
run: npm install
- name: Tests
run: npm test
test-go:
name: Go ${{ matrix.go_version }} on ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
go_version: [1.13.x, 1.14.x]
runs-on: ${{ matrix.os }}
steps:
- name: Install Go ${{ matrix.go }}
uses: actions/setup-go@v2-beta
with:
go-version: ${{ matrix.go_version }}
- name: Checkout code
uses: actions/checkout@v2
- name: Install make
run: choco install make
if: ${{ matrix.os == 'windows-latest' }}
- name: Install dependencies
run: make deps
- name: Tests
run: make test
32 changes: 0 additions & 32 deletions .travis.yml

This file was deleted.