|
| 1 | +# Licensed to the Apache Software Foundation (ASF) under one |
| 2 | +# or more contributor license agreements. See the NOTICE file |
| 3 | +# distributed with this work for additional information |
| 4 | +# regarding copyright ownership. The ASF licenses this file |
| 5 | +# to you under the Apache License, Version 2.0 (the |
| 6 | +# "License"); you may not use this file except in compliance |
| 7 | +# with the License. You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, |
| 12 | +# software distributed under the License is distributed on an |
| 13 | +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 | +# KIND, either express or implied. See the License for the |
| 15 | +# specific language governing permissions and limitations |
| 16 | +# under the License. |
| 17 | + |
| 18 | +name: Test Action |
| 19 | + |
| 20 | +on: |
| 21 | + push: |
| 22 | + branches-ignore: |
| 23 | + - 'dependabot/**' |
| 24 | + pull_request: |
| 25 | + branches: |
| 26 | + - '*' |
| 27 | + |
| 28 | +jobs: |
| 29 | + test-without-ratignore: |
| 30 | + name: Test without .ratignore |
| 31 | + runs-on: ubuntu-latest |
| 32 | + |
| 33 | + permissions: |
| 34 | + contents: read |
| 35 | + |
| 36 | + steps: |
| 37 | + - uses: actions/checkout@v5 |
| 38 | + |
| 39 | + - name: Use Case 1 - All Has License |
| 40 | + uses: ./ |
| 41 | + |
| 42 | + - name: Create missing header license files |
| 43 | + run: | |
| 44 | + echo "random string" > file-missing-license.txt |
| 45 | +
|
| 46 | + - name: Use Case 2 - File Missing License |
| 47 | + id: rat-failed-case |
| 48 | + continue-on-error: true |
| 49 | + uses: ./ |
| 50 | + |
| 51 | + - name: Verify Expected Fail Case |
| 52 | + run: | |
| 53 | + if [ "${{ steps.rat-failed-case.outcome }}" != "failure" ]; then |
| 54 | + echo "Expected Failure but Passed" |
| 55 | + exit 1 |
| 56 | + else |
| 57 | + echo "Correctly Failed" |
| 58 | + fi |
| 59 | +
|
| 60 | + test-with-ratignore: |
| 61 | + name: Test with .ratignore |
| 62 | + runs-on: ubuntu-latest |
| 63 | + |
| 64 | + permissions: |
| 65 | + contents: read |
| 66 | + |
| 67 | + steps: |
| 68 | + - uses: actions/checkout@v5 |
| 69 | + |
| 70 | + - name: Create .ratignore file |
| 71 | + # Creating a .ratignore file and ignoring itself & file-missing-license.txt. |
| 72 | + run: echo -e ".ratignore\nfile-missing-license.txt" > .ratignore |
| 73 | + |
| 74 | + - name: Create missing header license files |
| 75 | + run: | |
| 76 | + echo "random string" > file-missing-license.txt |
| 77 | +
|
| 78 | + - name: Testing Apache Creadur RAT Action (self-test) |
| 79 | + uses: ./ |
0 commit comments