All Projects → mvdan → Github Actions Golang

mvdan / Github Actions Golang

Licence: bsd-3-clause
GitHub Actions as CI for Go

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Projects that are alternatives of or similar to Github Actions Golang

Press
A continuous developement environment for Powershell Modules either via local development or leveraging GitHub and Github Actions
Stars: ✭ 21 (-96.87%)
Mutual labels:  modules, ci, cd
makes
A DevSecOps framework powered by Nix.
Stars: ✭ 158 (-76.49%)
Mutual labels:  ci, cd
changie
Automated changelog tool for preparing releases with lots of customization options
Stars: ✭ 180 (-73.21%)
Mutual labels:  ci, cd
bx-docker
Tutorial on how to build Docker Images for the IAR Build Tools on Linux hosts. The IAR Build Tools on Linux are available for Arm, RISC-V and Renesas (RH850, RL78 and RX).
Stars: ✭ 28 (-95.83%)
Mutual labels:  ci, cd
setup-scheme
Github Actions CI / CD setup for Scheme
Stars: ✭ 13 (-98.07%)
Mutual labels:  ci, cd
update-container-description-action
github action to update a Docker Hub, Quay or Harbor repository description from a README file
Stars: ✭ 20 (-97.02%)
Mutual labels:  ci, cd
rust-azure-pipelines
Collection of azure pipelines templates for rust
Stars: ✭ 43 (-93.6%)
Mutual labels:  ci, cd
flagsmith-js-client
Javascript Client for Flagsmith. Ship features with confidence using feature flags and remote config. Host yourself or use our hosted version at https://www.flagsmith.com/
Stars: ✭ 42 (-93.75%)
Mutual labels:  ci, cd
Nvwa Io
Nvwa-io is a open source DevOps CI/CD auto-build and auto-deploy system(女娲 - 开源 DevOps CI/CD 自动构建和自动部署系统). http://nvwa-io.com
Stars: ✭ 283 (-57.89%)
Mutual labels:  ci, cd
Awx Container
Ansible Container project that manages the lifecycle of AWX on Docker.
Stars: ✭ 294 (-56.25%)
Mutual labels:  ci, cd
Horusec
Horusec is an open source tool that improves identification of vulnerabilities in your project with just one command.
Stars: ✭ 311 (-53.72%)
Mutual labels:  ci, cd
docs
OOCLAB 开放文档中心
Stars: ✭ 14 (-97.92%)
Mutual labels:  ci, cd
test-infra
Falco workflow & testing infrastructure
Stars: ✭ 18 (-97.32%)
Mutual labels:  ci, cd
flagsmith-nodejs-client
Flagsmith Node JS Client. Flagsmith lets you manage features flags across web, mobile and server side applications. Get builds out faster. Control who has access to new features.
Stars: ✭ 13 (-98.07%)
Mutual labels:  ci, cd
dockerized-drupal-starter
End-to-end (CI + CD) dockerized Drupal 8 starting point.
Stars: ✭ 27 (-95.98%)
Mutual labels:  ci, cd
awesome
A curated list of delightful developers resources.
Stars: ✭ 13 (-98.07%)
Mutual labels:  ci, cd
Gitlab Ci Pipeline Php
☕️ Docker images for test PHP applications with Gitlab CI (or any other CI platform!)
Stars: ✭ 451 (-32.89%)
Mutual labels:  ci, cd
AzDo.VstsDashboard
Provide a simple way to view all Builds and Releases on a single page. The intend was to see what's currently happened into the CI/CD pipeline and provide quick feedback of what's going on.
Stars: ✭ 16 (-97.62%)
Mutual labels:  ci, cd
action-junit-report
Reports junit test results as GitHub Pull Request Check
Stars: ✭ 103 (-84.67%)
Mutual labels:  ci, cd
tichi
TiChi ☯️ contains the tidb community collaboration automation basic framework and tool set.
Stars: ✭ 36 (-94.64%)
Mutual labels:  ci, cd

GitHub Actions for Go

GitHub Actions includes CI/CD for free for Open Source repositories. This document contains information on making it work well for Go. See them in action:

$ cat .github/workflows/test.yml
on: [push, pull_request]
name: Test
jobs:
  test:
    strategy:
      matrix:
        go-version: [1.15.x, 1.16.x]
        os: [ubuntu-latest, macos-latest, windows-latest]
    runs-on: ${{ matrix.os }}
    steps:
    - name: Install Go
      uses: actions/[email protected]
      with:
        go-version: ${{ matrix.go-version }}
    - name: Checkout code
      uses: actions/[email protected]
    - name: Test
      run: go test ./...

Summary

Each workflow file has a number of jobs, which get run on specified events, and run concurrently with each other. You can have workflow status badges.

Each job runs on a configuration matrix. For example, we can test two major Go versions on three operating systems.

Each job has a number of steps, such as installing Go, or checking out the repository's code.

FAQs

What about module support?

If your repository contains a go.mod file, Go 1.12 and later will already use module mode by default. To turn it on explicitly, set GO111MODULE=on.

How do I set environment variables?

They can be set up via env for an entire workflow, a job, or for each step:

env:
  GOPROXY: "https://proxy.company.com"
jobs:
  [...]

How do I set environment variables at run-time?

You can use environment files to set environment variables or add an element to $PATH. For example:

steps:
- name: Set env vars
  run: |
      echo "CGO_ENABLED=0" >> $GITHUB_ENV
      echo "${HOME}/goroot/bin" >> $GITHUB_PATH

Note that these take effect for future steps in the job.

How do I set up caching between builds?

Use actions/cache. For example, to cache downloaded modules:

- uses: actions/[email protected]
  with:
    path: ~/go/pkg/mod
    key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
    restore-keys: |
      ${{ runner.os }}-go-

You can also include Go's build cache, to improve incremental builds:

- uses: actions/[email protected]
  with:
    # In order:
    # * Module download cache
    # * Build cache (Linux)
    # * Build cache (Mac)
    # * Build cache (Windows)
    path: |
      ~/go/pkg/mod
      ~/.cache/go-build
      ~/Library/Caches/go-build
      %LocalAppData%\go-build
    key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
    restore-keys: |
      ${{ runner.os }}-go-

This is demonstrated via the test-cache job in this very repository.

See this guide for more details.

How do I run a step conditionally?

You can use if conditionals, using their custom expression language:

- name: Run end-to-end tests on Linux
  if: github.event_name == 'push' && matrix.os == 'ubuntu-latest'
  run: go run ./endtoend

How do I set up a custom build matrix?

You can include extra matrix jobs, and you can exclude specific matrix jobs.

How do I run multiline scripts?

- name: Series of commands
  run: |
    go test ./...
    go test -race ./...

Should I use two workflows, or two jobs on one workflow?

The biggest difference is the UI; workflow results are shown separately. Grouping jobs in workflows can also be useful if one wants to customize the workflow triggers, or to set up dependencies via needs.

How do I set up a secret environment variable?

Follow these steps to set up the secret in the repo's settings. After adding a secret like FOO_SECRET, use it on a step as follows:

- name: Command that requires secret
  run: some-command
  env:
    FOO_SECRET: ${{ secrets.FOO_SECRET }}

How do I install private modules?

It's possible to install modules from private GitHub repositories without using your own proxy. You'll need to add a personal access token as a secret environment variable, as well as configure GOPRIVATE.

- name: Configure git for private modules
  env:
    TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
  run: git config --global url."https://YOUR_GITHUB_USERNAME:${TOKEN}@github.com".insteadOf "https://github.com"
env:
  GOPRIVATE: "*.company.com"
jobs:
  [...]

How do I install Linux packages?

Use sudo apt, making sure to only run the step on Linux:

- name: Install Linux packages
  if: matrix.os == 'ubuntu-latest'
  run: sudo apt update && sudo apt install -y --no-install-recommends mypackage

How do I set up a GOPATH build?

Declare GOPATH and clone inside of it:

jobs:
  test-gopath:
    env:
      GOPATH: ${{ github.workspace }}
      GO111MODULE: off
    defaults:
      run:
        working-directory: ${{ env.GOPATH }}/src/github.com/${{ github.repository }}
    steps:
    - name: Checkout code
      uses: actions/[email protected]
      with:
        path: ${{ env.GOPATH }}/src/github.com/${{ github.repository }}

Quick links

Caveats

git config core.autocrlf defaults to true, so be careful about CRLF endings in your plaintext testdata files on Windows. To work around this, set up the following .gitattributes:

* -text

os.TempDir on Windows will contain a short name, since %TEMP% also contains it. Note that case sensitivity doesn't matter, and that os.Open should still work; but some programs not treating short names might break.

> echo %USERPROFILE%
C:\Users\runneradmin
> echo %TEMP%
C:\Users\RUNNER~1\AppData\Local\Temp
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].