Skip to content

Commit

Permalink
run CI on GitHub Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
zupo committed Jul 13, 2023
1 parent 221e644 commit b4d2927
Show file tree
Hide file tree
Showing 9 changed files with 174 additions and 221 deletions.
179 changes: 0 additions & 179 deletions .circleci/config.yml

This file was deleted.

23 changes: 23 additions & 0 deletions .github/actions/nix-shell/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: "Prepare nix-shell"
description:
Download cache, build nix-shell and potentially upload any new
derivations to cache

inputs:
cachix_auth_token:
required: true

runs:
using: "composite"
steps:
- uses: cachix/install-nix-action@v22
with:
nix_path: nixpkgs=channel:nixos-unstable
- uses: cachix/cachix-action@v12
with:
name: niteo-public
authToken: '${{ inputs.cachix_auth_token }}'

- name: Build nix-shell
shell: bash
run: nix-shell --run "echo 'nix-shell successfully entered'"
16 changes: 16 additions & 0 deletions .github/actions/uncommitted-changes/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: "Uncommitted Changes"
description:
Fail if any uncommitted changes are detected.

runs:
using: "composite"
steps:
- uses: tj-actions/verify-changed-files@v14
id: verify-changed-files

- name: List all changed files tracked and untracked files
if: steps.verify-changed-files.outputs.files_changed == 'true'
shell: bash
run: |
echo "Changed files: ${{ steps.verify-changed-files.outputs.changed_files }}"
exit 1
58 changes: 58 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Run all tests, linters, code analysis and other QA tasks on
# every push to main and PRs.
#
# To SSH into the runner to debug a failure, add the following step before
# the failing step
# - uses: lhotari/action-upterm@v1
# with:
# limit-access-to-actor: true

name: CI

on:
workflow_dispatch:
pull_request:
push:
branches:
- main


# Prevent multiple jobs running after fast subsequent pushes
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:

tests:
name: Tests

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/nix-shell
with:
cachix_auth_token: '${{ secrets.CACHIX_AUTH_TOKEN_PUBLIC }}'

- run: nix-shell --run "make lint all=true"

- run: nix-shell --run "make tests"

- run: nix-shell --run "make dist"

- uses: ./.github/actions/uncommitted-changes

# yamllint disable
# TODO: publishing workflow
# steps:
# - checkout

# - configure_nix

# - run:
# name: Authenticate with registry
# command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/salarycalc/.npmrc

# - run:
# name: Publish the package to NPM
# command: nix-shell --run "npm version --no-git-tag-version prerelease --preid $(date +%Y-%m-%dT%H-%M-%S) && make dist && npm publish"
43 changes: 43 additions & 0 deletions .github/workflows/nix-gh-cache.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Build derivations for Linux and Apple Silicon and upload them to
# Cachix

name: Nix Cache

on:
push:
paths:
- "**.nix"
- "**.lock"
- "**package.json"
- "**pyproject.toml"
- ".github/**.ya?ml"
workflow_dispatch:

# Kill running jobs if a new commit is pushed to PR, or someone restarts
# a job that is already running.
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:

prime:
name: Prime Cachix

strategy:
# Keep building other OSes even if one fails
fail-fast: false
matrix:
# ubuntu-latest-16-cores: Hosted GHA Linux runner, larger than default
# so that this job primes the cache as much as possible before
# other jobs that depend on the cache start running
# macos-latest: Hosted GHA Intel-based MAC runner
# macos-m1: TODO, GitHub says they will be available in Q4
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/nix-shell
with:
cachix_auth_token: '${{ secrets.CACHIX_AUTH_TOKEN_PUBLIC }}'
22 changes: 7 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,16 @@ all: tests dist
.PHONY: lock
lock:
@rm -rf .venv/
@poetry lock
@poetry lock --no-update
@rm -rf .venv/
@rm -rf node_modules
@elm2nix convert > elm-srcs.nix
@elm2nix snapshot > registry.dat
@nix-shell --run true
@direnv reload
@echo "-e ." >> requirements.txt
@nix-build shell.nix -A inputDerivation | cachix push niteo
@rm result

# Build distribution files and place them where they are expected
.PHONY: dist
Expand Down Expand Up @@ -43,27 +47,15 @@ endif
test: tests

.PHONY: tests
tests: coverage

.PHONY: coverage
coverage: verify-examples
@elm-coverage --report codecov

.PHONY: verify-examples
verify-examples:
tests:
@elm-verify-examples

.coverage/codecov.json: test
@elm-test

# Run development server
.PHONY: run
run:
@parcel --global SalaryCalculator src/index.html

.PHONY: codecov
codecov: .coverage/codecov.json
@codecov --disable=gcov --file=.coverage/codecov.json


# Fetch salaries, location factors and currencies from the Internet
.PHONY: config
Expand Down
Loading

0 comments on commit b4d2927

Please sign in to comment.