Skip to content

Use Javascript action instead of composite action' #253

Use Javascript action instead of composite action'

Use Javascript action instead of composite action' #253

Workflow file for this run

name: Continuous integration
on:
push:
branches: main
pull_request:
branches: main
workflow_dispatch: # allows manual triggering
schedule:
- cron: '1 11 * * *'
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}
jobs:
unit_tests:
name: Unit Tests
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout the repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- uses: ./.github/actions/set_up_runner
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Execute Bazel tests
shell: bash
run: bazel test //...
integration_tests:
name: Integration Tests
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout the repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- uses: ./.github/actions/set_up_runner
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Execute in directory with shell.nix
uses: ./
with:
verbose: true
# Demonstrate passing a directory that contains a shell.nix.
derivation-path: ./tests/integration_tests
working-directory: ./tests/integration_tests
options: |
--arg customVarBool true
--argstr customVarStr "Hello, World!"
run: |
echo "FIRST" > integration_test.out
echo "${CUSTOM_VAR_BOOL}" >> integration_test.out
echo "${CUSTOM_VAR_STR}" >> integration_test.out
- name: Confirm output for Execute in directory with shell.nix
shell: bash
run: |
output="$(<./tests/integration_tests/integration_test.out)"
expected="$(cat <<-EOF
FIRST
true
Hello, World!
EOF
)"
[[ "${output}" == "${expected}" ]] || \
(echo >&2 "Ouptput from integration test does not match:" "${output}"; exit 1)
- name: Execute in directory without shell.nix
uses: ./
with:
verbose: true
# Demonstrate passing a path to a shell.nix.
derivation-path: ./tests/integration_tests/shell.nix
options: |
--argstr customVarStr "Hello, World!"
run: |
echo "${CUSTOM_VAR_STR}" >> integration_test2.out
- name: Confirm output for Execute in directory without shell.nix
shell: bash
run: |
output="$(<./integration_test2.out)"
expected="$(cat <<-EOF
Hello, World!
EOF
)"
[[ "${output}" == "${expected}" ]] || \
(echo >&2 "Ouptput from integration test does not match:" "${output}"; exit 1)
- name: Execute without recommended shell flags
uses: ./
with:
verbose: true
derivation-path: ./tests/integration_tests
shell-flags: ''
run: |
rm -f integration_test3.out
# This fails. If the recommended flags are set, we should not reach the following
# statement.
ls does_not_exist
echo "HELLO" > integration_test3.out
- name: Confirm output for Execute without recommended shell flags
shell: bash
run: |
[[ -e integration_test3.out ]] || \
(echo >&2 "The integration_test3.out does not exist."; exit 1)
output="$(<./integration_test3.out)"
expected="$(cat <<-EOF
HELLO
EOF
)"
[[ "${output}" == "${expected}" ]] || \
(echo >&2 "Ouptput from integration test does not match:" "${output}"; exit 1)
- name: Execute with recommended shell flags
# This step should fail. We will confirm that it failed as expected in the next step.
continue-on-error: true
uses: ./
with:
verbose: true
derivation-path: ./tests/integration_tests
run: |
rm -f integration_test4.out
# This fails. If the recommended flags are set, we should not reach the following
# statement.
ls does_not_exist
echo "HELLO" > integration_test4.out
- name: Confirm output for Execute with recommended shell flags
shell: bash
run: |
if [[ -e integration_test4.out ]]; then
echo >&2 "The integration_test4.out exists."
exit 1
fi
echo "SUCCESS"
- name: Execute with output
id: sample
uses: ./
with:
derivation-path: ./tests/integration_tests
pure: false
run: |-
echo "what=thing" >> "$GITHUB_OUTPUT"
- name: Confirm that output was propagated
shell: bash
run: |-
actual='${{ steps.sample.outputs.what }}'
if [[ "$actual" != 'thing' ]]; then
echo >&2 "The output from \`sample\` was wrong. Wanted \`thing\` but got \`${actual}\`"
exit 1
fi
all_ci_tests:
runs-on: ubuntu-latest
needs:
- unit_tests
- integration_tests
if: ${{ always() }}
steps:
- uses: cgrindel/gha_join_jobs@794a2d117251f22607f1aab937d3fd3eaaf9a2f5 # v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}