-
Notifications
You must be signed in to change notification settings - Fork 32
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
ci: Add GitHub Actions workflow #21
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
use nix |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# This file lints the code and runs tests. | ||
name: CI | ||
|
||
on: | ||
pull_request: | ||
push: | ||
|
||
env: | ||
COMPOSER_FLAGS: "--ansi --no-interaction --no-progress --no-suggest --prefer-dist" | ||
|
||
jobs: | ||
tests: | ||
runs-on: ubuntu-20.04 | ||
strategy: | ||
matrix: | ||
php: | ||
- '8.0' | ||
- '7.4' | ||
- '7.3' | ||
- '7.2' | ||
- '7.1' | ||
- '7.0' | ||
- '5.6' | ||
include: | ||
- php: '7.0' | ||
cs_fixer: true | ||
name: 'Check with PHP ${{ matrix.php }}' | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Install Nix | ||
uses: cachix/install-nix-action@v12 | ||
|
||
- name: Set up Nix cache | ||
uses: cachix/cachix-action@v8 | ||
with: | ||
# Use cache from https://github.com/fossar/nix-phps | ||
name: fossar | ||
|
||
- name: Update flake.nix to match the current CI job from matrix | ||
run: sed -i 's/matrix.phpPackage = "php";/matrix.phpPackage = builtins.replaceStrings ["."] [""] "php${{ matrix.php }}";/' flake.nix | ||
|
||
- name: Get Composer Cache Directory | ||
id: composer-cache | ||
run: | | ||
echo "::set-output name=dir::$(composer config cache-files-dir)" | ||
|
||
- uses: actions/cache@v2 | ||
env: | ||
cache-name: cache-composer-modules | ||
with: | ||
path: ${{ steps.composer-cache.outputs.dir }} | ||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-composer- | ||
|
||
- name: Install dependencies | ||
run: nix-shell --run 'composer install' | ||
|
||
- name: Lint source code | ||
if: matrix.cs_fixer | ||
run: nix-shell --run 'composer cs-check' | ||
|
||
- name: Run unit tests | ||
run: nix-shell --run 'composer test' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{ | ||
description = "An open-source PHP library for image manipulation"; | ||
|
||
inputs = { | ||
# For old PHP versions. | ||
phps.url = "github:fossar/nix-phps"; | ||
}; | ||
|
||
outputs = { self, phps }: | ||
let | ||
# nixpkgs is a repository with software packages and some utilities. | ||
# From simplicity, we inherit it from the phps flake. | ||
inherit (phps.inputs) nixpkgs; | ||
|
||
# Configure the development shell here (e.g. for CI). | ||
|
||
# By default, we use the default PHP version from Nixpkgs. | ||
matrix.phpPackage = "php"; | ||
in | ||
let | ||
# We only support a single platform at the moment, | ||
# since our binary cache only contains PHP packages for that. | ||
system = "x86_64-linux"; | ||
|
||
# Get Nixpkgs packages for current platform. | ||
pkgs = nixpkgs.legacyPackages.${system}; | ||
|
||
# Create a PHP package from the selected PHP package. | ||
php = phps.packages.${system}.${matrix.phpPackage}; | ||
in { | ||
# Expose shell environment for development. | ||
devShell.${system} = pkgs.mkShell { | ||
nativeBuildInputs = [ | ||
# Composer and PHP. | ||
php | ||
php.packages.composer | ||
]; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
(import ( | ||
let | ||
lock = builtins.fromJSON (builtins.readFile ./flake.lock); | ||
in fetchTarball { | ||
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; | ||
sha256 = lock.nodes.flake-compat.locked.narHash; } | ||
) { | ||
src = ./.; | ||
}).shellNix |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The way Nix works, it takes build instructions for packages and builds them. It can also substitute the build result from a cache to reduce work. But since these are custom packages, they are not built by the official build servers and we need to use our own cache. I added a comment with a link to the repository that builds it.