Test #402
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
name: "Test" | |
on: | |
push: | |
schedule: | |
- cron: '40 0 * * *' # run every night | |
jobs: | |
test: | |
strategy: | |
matrix: | |
shellSource: [packages, flakes, file, devShell] | |
runs-on: [ubuntu-latest, macos-latest] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
# Don't install `nix` ourselves to ensure that the action does. | |
# Check that we've got the default Actions Runner path: | |
- run: echo $PATH && rustc --version | |
# Map to the right shell source: | |
- name: 'Load Shell Env' | |
uses: ./.github/workflows/matrix-expansion-helper | |
with: | |
source: ${{ matrix.shellSource }} | |
packages: hello | |
flakes: nixpkgs#hello | |
file: test/shell.nix | |
devShell: ./test | |
preserveDefaultPath: false | |
extraNixOptions: | | |
--option access-tokens github.com=${{ secrets.GITHUB_TOKEN }} | |
# Test that the PATH has been cleared now: | |
- run: | | |
echo $PATH | |
command -v rustc && exit 1 || : | |
# Test that `hello` is on the path: | |
- run: hello | |
# `devShell` and `file` sources also exported the test case vars; check | |
# that the vars roundtripped correctly in these shells: | |
- name: 'Check Env Var Roundtrip Testcases' | |
if: ${{ (matrix.shellSource == 'devShell') || (matrix.shellSource == 'file') }} | |
run: | | |
bash -c "source util.bash; check_testcases" | |
# Check that modifications in `shellHook` take effect: | |
echo $PATH | grep "foo" || exit 3 | |
# Note that `bash` is *not* on the path now.. | |
# | |
# (but only for the flakes route since that's the only route here that's | |
# not `mkShell` based and thus doesn't dump the stdenv's bash/coreutils on | |
# $PATH) | |
- if: ${{ matrix.shellSource == 'flakes' }} | |
run: | | |
! command -v bash | |
- name: 'Run Script with Host Env' | |
uses: ./.github/workflows/matrix-expansion-helper | |
with: | |
source: ${{ matrix.shellSource }} | |
packages: bash, tiny | |
flakes: nixpkgs#bash, nixpkgs#tiny | |
file: test/shell2.nix | |
devShell: ./test#noHello | |
extraNixOptions: | | |
--option access-tokens github.com=${{ secrets.GITHUB_TOKEN }} | |
exportEnv: false | |
clearEnvForScript: false | |
script: | | |
hello # should still be available because we didn't clear the env | |
tiny --version | |
touch foo | |
# check that we didn't add python to the github actions env: | |
- name: 'Did not update environment' | |
run: | | |
command -v tiny && exit 3 || : | |
[[ -e foo ]] # check that the script actually ran | |
# Test that we can run with non-interactive bash on $PATH: | |
- name: 'Put non-interactive bash on $PATH' | |
uses: ./ | |
with: | |
packages: bash | |
- run: | | |
! bash -c "type compgen" | |
- name: 'Run Script without Host Env' | |
uses: ./.github/workflows/matrix-expansion-helper | |
with: | |
source: ${{ matrix.shellSource }} | |
packages: bash | |
flakes: nixpkgs#bash | |
file: test/shell2.nix | |
devShell: ./test#noHello | |
extraNixOptions: | | |
--option access-tokens github.com=${{ secrets.GITHUB_TOKEN }} | |
exportEnv: false | |
clearEnvForScript: true | |
script: | | |
hello && exit 3 || : okay # shouldn't be there anymore | |
- name: 'Run Script with Other Interpreter' | |
uses: ./.github/workflows/matrix-expansion-helper | |
with: | |
source: ${{ matrix.shellSource }} | |
packages: python3 | |
flakes: nixpkgs#python3 | |
file: test/shell2.nix | |
devShell: ./test#noHello | |
extraNixOptions: | | |
--option access-tokens github.com=${{ secrets.GITHUB_TOKEN }} | |
exportEnv: false | |
clearEnvForScript: true | |
interpreter: python3 | |
script: | | |
import os | |
print(os.sys.version) | |
print(os.environ['PATH']) | |
# TODO: run in shell with `clearEnvForScript` and not; check that outside stuff is available/is not available |