diff --git a/.travis.yml b/.travis.yml index 6c4f9eb035..bf8d94f356 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,29 +1,28 @@ -# 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: @@ -31,29 +30,37 @@ cache: - $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 'builds@travis-ci.org' - - 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 diff --git a/flake.nix b/flake.nix index d3f9364b49..9845ab0aad 100644 --- a/flake.nix +++ b/flake.nix @@ -14,6 +14,8 @@ outputs = { self, flake-compat, nixpkgs, utils }: let + matrix.php = "php"; + mkDevShell = pkgs: phpPackage: let php = pkgs.${phpPackage}.withExtensions ({ enabled, all }: with all; enabled ++ [ @@ -31,6 +33,7 @@ pkgs.zola pkgs.nodejs_latest python + pkgs.jq ] ++ (with php.packages; [ composer psalm @@ -50,7 +53,7 @@ packages = { inherit (pkgs) php56 php70 php71 php72; }; - devShell = mkDevShell pkgs "php"; + devShell = mkDevShell pkgs matrix.php; } ); }