-
Notifications
You must be signed in to change notification settings - Fork 345
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Previously we were installing - PHP using Travis’s built-in mechanism that downloads distributions-specific tarballs (PHP 7.1 is not compatible with focal), - Composer using itself, - Python using pyenv (quite slow), - Python libraries using pip, - Node using nvm, - jq using apt, - PHP dependencies using Composer, - client-side dependencies using npm. Switching to Nix will allow us to get rid of all except the last two methods and achieve fully reproducible environment across both CI and developers’ machines. The travis config is based on https://github.com/cachix/travis-ci-example. Also allows us to switch distribution to focal.
- Loading branch information
Showing
2 changed files
with
47 additions
and
37 deletions.
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 |
---|---|---|
@@ -1,59 +1,66 @@ | ||
# This file lints the code, builds a package and then deploys it. | ||
# For the deployment, $BINTRAY_USER, $BINTRAY_KEY and $GH_TOKEN environment | ||
# variables need to be set. | ||
language: php | ||
# This file lints the code, runs tests, builds a package and then deploys it. | ||
# The following environment variables need to be set: | ||
# - “$BINTRAY_USER” and “$BINTRAY_KEY” for pushing built package to Bintray | ||
# - “$GH_TOKEN” to avoid Composer being throttled by GitHub | ||
# - “$CACHIX_AUTH_TOKEN” for uploading built Nix packages to Cachix | ||
language: nix | ||
dist: focal | ||
nix: 2.3.9 | ||
sudo: false | ||
|
||
dist: xenial | ||
env: | ||
global: | ||
- CACHIX_CACHE=fossar | ||
- COMPOSER_NO_INTERACTION=1 | ||
|
||
matrix: | ||
include: | ||
- php: 8.0 | ||
- php: 7.4 | ||
- php: 7.3 | ||
- php: 7.2 | ||
- php: 7.1 | ||
- php: 7.0 | ||
env: CS_FIXER=true LINT_JS=true | ||
- php: 5.6 | ||
env: DEPLOY=true | ||
- env: PHP=80 | ||
- env: PHP=74 | ||
- env: PHP=73 | ||
- env: PHP=72 | ||
- env: PHP=71 | ||
- env: PHP=70 CS_FIXER=true LINT_JS=true | ||
- env: PHP=56 DEPLOY=true | ||
fast_finish: true | ||
env: | ||
- COMPOSER_NO_INTERACTION=1 | ||
|
||
addons: | ||
apt: | ||
packages: | ||
- jq | ||
|
||
cache: | ||
directories: | ||
- vendor | ||
- $HOME/.composer/cache | ||
|
||
before_install: | ||
- nvm install 12 | ||
- pyenv install 3.6.3 | ||
- pyenv global 3.6.3 | ||
- pip3 install requests bcrypt | ||
- if [ -n "$GH_TOKEN" ]; then composer config github-oauth.github.com ${GH_TOKEN}; fi | ||
- composer self-update | ||
# Nix & Cachix set-up. | ||
- echo "trusted-users = $USER" | sudo tee -a /etc/nix/nix.conf | ||
- sudo systemctl restart nix-daemon | ||
- nix-env -iA nixpkgs.cachix | ||
- cachix use $CACHIX_CACHE | ||
- nix path-info --all > /tmp/store-path-pre-build | ||
|
||
# Update flake.nix to match the current CI job from matrix. | ||
- sed -i "s/matrix.php = \"php\";/matrix.php = \"php${PHP}\";/" flake.nix | ||
|
||
- if [ -n "$GH_TOKEN" ]; then nix-shell --run "composer config github-oauth.github.com ${GH_TOKEN}"; fi | ||
|
||
install: | ||
- phpenv config-rm xdebug.ini | ||
- npm run install-dependencies | ||
- nix-shell --run "npm run install-dependencies" | ||
|
||
script: | ||
- if [ "$LINT_JS" = true ]; then npm run lint:client; fi | ||
- npm run lint:server | ||
- if [ "$CS_FIXER" = true ]; then npm run cs:server; fi | ||
- npm run test:server | ||
- npm run test:integration | ||
- if [ "$LINT_JS" = true ]; then nix-shell --run "npm run lint:client"; fi | ||
- nix-shell --run "npm run lint:server" | ||
- if [ "$CS_FIXER" = true ]; then nix-shell --run "npm run cs:server"; fi | ||
- nix-shell --run "npm run test:server" | ||
- nix-shell --run "npm run test:integration" | ||
|
||
after_success: | ||
# Upload built Nix packages to Cachix. | ||
- comm -13 <(sort /tmp/store-path-pre-build | grep -v '\.drv$') <(nix path-info --all | grep -v '\.drv$' | sort) | cachix push $CACHIX_CACHE | ||
|
||
before_deploy: | ||
- git config --global user.email 'Travis CI' | ||
- git config --global user.name '[email protected]' | ||
- source utils/package.sh | ||
- source utils/bintray.sh | ||
- nix-shell --run "source utils/package.sh" | ||
- nix-shell --run "source utils/bintray.sh" | ||
|
||
deploy: | ||
- provider: bintray | ||
|
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