|
| 1 | +# End-to-end tests for the Publish to BCR custom GitHub action |
| 2 | +name: action-e2e |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + pull_request: |
| 7 | + branches: [main] |
| 8 | + workflow_dispatch: |
| 9 | +concurrency: |
| 10 | + # Cancel previous actions from the same PR or branch except 'main' branch. |
| 11 | + # See https://docs.github.com/en/actions/using-jobs/using-concurrency and https://docs.github.com/en/actions/learn-github-actions/contexts for more info. |
| 12 | + group: concurrency-group::${{ github.workflow }}::${{ github.event.pull_request.number > 0 && format('pr-{0}', github.event.pull_request.number) || github.ref_name }}${{ github.ref_name == 'main' && format('::{0}', github.run_id) || ''}} |
| 13 | + cancel-in-progress: ${{ github.ref_name != 'main' }} |
| 14 | +jobs: |
| 15 | + # Each job is an e2e test. Unfortunately a full workflow cannot be added as |
| 16 | + # required status check on branch protection rules, so each test must be added |
| 17 | + # as a required check: https://github.com/orgs/community/discussions/12395. |
| 18 | + test-happy-path: |
| 19 | + # Create a new module entry and test the content |
| 20 | + runs-on: ubuntu-latest |
| 21 | + steps: |
| 22 | + - uses: actions/checkout@v2 |
| 23 | + with: |
| 24 | + path: this |
| 25 | + - name: Setup test fixture |
| 26 | + run: this/e2e/action/setup-test-fixture.sh versioned versioned-1.0.0 |
| 27 | + - name: Create registry |
| 28 | + run: | |
| 29 | + mkdir -p bazel-central-registry/modules |
| 30 | + cd bazel-central-registry |
| 31 | + git init |
| 32 | + - name: Create entry |
| 33 | + uses: ./this |
| 34 | + with: |
| 35 | + tag: v1.0.0 |
| 36 | + module-version: 1.0.0 |
| 37 | + github-repository: foobar/versioned |
| 38 | + templates-dir: this/e2e/fixtures/versioned/.bcr |
| 39 | + local-registry: bazel-central-registry |
| 40 | + - name: Test entry content |
| 41 | + run: this/e2e/action/test-happy-path-content.sh |
| 42 | + test-github-repository-default: |
| 43 | + # Test that the `github-repository` input defaults to ${{ github.repository }} |
| 44 | + # indirectly by checking the resulting subtituted source.json file in the entry. |
| 45 | + runs-on: ubuntu-latest |
| 46 | + steps: |
| 47 | + - uses: actions/checkout@v2 |
| 48 | + with: |
| 49 | + path: this |
| 50 | + - name: Setup test fixture |
| 51 | + run: this/e2e/action/setup-test-fixture.sh versioned publish-to-bcr-1.0.0 |
| 52 | + - name: Create registry |
| 53 | + run: | |
| 54 | + mkdir -p bazel-central-registry/modules |
| 55 | + cd bazel-central-registry |
| 56 | + git init |
| 57 | + - name: Create entry |
| 58 | + uses: ./this |
| 59 | + with: |
| 60 | + tag: v1.0.0 |
| 61 | + module-version: 1.0.0 |
| 62 | + templates-dir: this/e2e/fixtures/versioned/.bcr |
| 63 | + local-registry: bazel-central-registry |
| 64 | + - name: Test repository substitution |
| 65 | + run: this/e2e/action/test-github-repository-default-substitution.sh |
0 commit comments