tests.yaml 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. # Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. # Exceptions. See /LICENSE for license information.
  3. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. name: Tests
  5. on:
  6. push:
  7. branches: [trunk, action-test]
  8. pull_request:
  9. merge_group:
  10. permissions:
  11. contents: read # For actions/checkout.
  12. pull-requests: read # For dorny/paths-filter to read pull requests.
  13. # Cancel previous workflows on the PR when there are multiple fast commits.
  14. # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#concurrency
  15. concurrency:
  16. group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
  17. cancel-in-progress: true
  18. jobs:
  19. test:
  20. strategy:
  21. matrix:
  22. # Test a recent version of each supported OS.
  23. runner: ['ubuntu-22.04', 'macos-14']
  24. build_mode: [fastbuild, opt]
  25. runs-on: ${{ matrix.runner }}
  26. steps:
  27. - name: Harden Runner
  28. uses: step-security/harden-runner@58077d3c7e43986b6b15fba718e8ea69e387dfcc # v2.15.1
  29. with:
  30. egress-policy: block
  31. # When adding endpoints, see README.md.
  32. # prettier-ignore
  33. allowed-endpoints: >
  34. *.blob.storage.azure.net:443
  35. *.githubapp.com:443
  36. *.sourceforge.net:443
  37. api.github.com:443
  38. api.ipify.org:443
  39. bcr.bazel.build:443
  40. downloads.sourceforge.net:443
  41. files.pythonhosted.org:443
  42. github.com:443
  43. go.dev:443
  44. mirror.bazel.build:443
  45. mirrors.kernel.org:443
  46. nodejs.org:443
  47. oauth2.googleapis.com:443
  48. objects.githubusercontent.com:443
  49. pypi.org:443
  50. registry.npmjs.org:443
  51. release-assets.githubusercontent.com:443
  52. releases.bazel.build:443
  53. storage.googleapis.com:443
  54. uploads.github.com:443
  55. www.googleapis.com:443
  56. - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
  57. - id: test-setup
  58. uses: ./.github/actions/test-setup
  59. with:
  60. matrix_runner: ${{ matrix.runner }}
  61. base_sha:
  62. ${{ github.event_name == 'pull_request' &&
  63. github.event.pull_request.base.sha ||
  64. github.event.merge_group.base_sha }}
  65. remote_cache_key: ${{ secrets.CARBON_BUILDS_GITHUB }}
  66. targets_file: ${{ runner.temp }}/targets
  67. # Build and run just the tests impacted by the PR or merge group.
  68. - name: Test (${{ matrix.build_mode }})
  69. if: steps.test-setup.outputs.has_code == 'true'
  70. shell: bash
  71. env:
  72. # 'libtool_check_unique failed to generate' workaround.
  73. # https://github.com/bazelbuild/bazel/issues/14113#issuecomment-999794586
  74. BAZEL_USE_CPP_ONLY_TOOLCHAIN: 1
  75. TARGETS_FILE: ${{ runner.temp }}/targets
  76. run: |
  77. # Decrease the jobs sharply if we see repeated failures to try to
  78. # work around transient network errors even if it makes things
  79. # slower.
  80. ./scripts/run_bazel.py \
  81. --attempts=5 --jobs-on-last-attempt=4 \
  82. test -c ${{ matrix.build_mode }} \
  83. --target_pattern_file=$TARGETS_FILE
  84. # See "Disk space before build" in `test-setup`.
  85. - name: Disk space after build
  86. if: steps.test-setup.outputs.has_code == 'true'
  87. run: df -h