|
| 1 | +name: Integration Tests |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + workflow_run: |
| 6 | + workflows: ['CI'] |
| 7 | + branches: |
| 8 | + - main |
| 9 | + - 'releases/*' |
| 10 | + types: |
| 11 | + - completed |
| 12 | + |
| 13 | +jobs: |
| 14 | + integration-tests: |
| 15 | + name: Integration Test |
| 16 | + runs-on: ubuntu-latest |
| 17 | + if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }} |
| 18 | + |
| 19 | + strategy: |
| 20 | + matrix: |
| 21 | + include: |
| 22 | + - auth: PAT |
| 23 | + owner: dsanders11 |
| 24 | + project_number: 11 |
| 25 | + - auth: PAT |
| 26 | + owner: dsanders11-playground-org |
| 27 | + project_number: 2 |
| 28 | + - auth: GHA |
| 29 | + owner: dsanders11-playground-org |
| 30 | + project_number: 2 |
| 31 | + |
| 32 | + steps: |
| 33 | + - name: Checkout |
| 34 | + id: checkout |
| 35 | + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 |
| 36 | + |
| 37 | + - name: Get Date |
| 38 | + uses: ./github-script/ |
| 39 | + id: get-date |
| 40 | + with: |
| 41 | + result-encoding: string |
| 42 | + script: | |
| 43 | + return new Date().toISOString() |
| 44 | +
|
| 45 | + - name: Generate GitHub App Token |
| 46 | + uses: electron/github-app-auth-action@384fd19694fe7b6dcc9a684746c6976ad78228ae # v1.1.1 |
| 47 | + id: generate-app-token |
| 48 | + if: ${{ matrix.auth == 'GHA' }} |
| 49 | + with: |
| 50 | + creds: ${{ secrets.GH_APP_CREDS }} |
| 51 | + org: ${{ matrix.owner }} |
| 52 | + |
| 53 | + - name: Get Auth Token |
| 54 | + id: get-auth-token |
| 55 | + run: echo "token=${{ steps.generate-app-token.outputs.token || secrets.PAT }}" >> "$GITHUB_OUTPUT" |
| 56 | + |
| 57 | + - name: Create Template View |
| 58 | + uses: ./github-script/ |
| 59 | + id: template-view |
| 60 | + with: |
| 61 | + script: | |
| 62 | + return { |
| 63 | + "type": "Favorite", |
| 64 | + "foo": "bar" |
| 65 | + } |
| 66 | +
|
| 67 | + - name: Copy Project |
| 68 | + uses: ./copy-project/ |
| 69 | + id: copy-project |
| 70 | + with: |
| 71 | + drafts: true |
| 72 | + owner: ${{ matrix.owner }} |
| 73 | + project-number: ${{ matrix.project_number }} |
| 74 | + # public: true |
| 75 | + target-owner: ${{ matrix.owner }} |
| 76 | + template-view: ${{ steps.template-view.outputs.result }} |
| 77 | + title: Integration Test Project |
| 78 | + token: ${{ steps.get-auth-token.outputs.token }} |
| 79 | + |
| 80 | + - name: Get Draft Issue ID |
| 81 | + id: get-draft-issue-id |
| 82 | + run: | |
| 83 | + set -eo pipefail |
| 84 | + echo "id=$(gh project item-list ${{ steps.copy-project.outputs.number }} --owner ${{ steps.copy-project.outputs.owner }} --format json | jq -r '.items[0] | .id')" >> "$GITHUB_OUTPUT" |
| 85 | + env: |
| 86 | + GH_TOKEN: ${{ steps.get-auth-token.outputs.token }} |
| 87 | + |
| 88 | + - name: Get Draft Issue |
| 89 | + uses: ./get-item/ |
| 90 | + id: get-draft-issue |
| 91 | + with: |
| 92 | + field: Priority |
| 93 | + item: ${{ steps.get-draft-issue-id.outputs.id }} |
| 94 | + owner: ${{ steps.copy-project.outputs.owner }} |
| 95 | + project-number: ${{ steps.copy-project.outputs.number }} |
| 96 | + token: ${{ steps.get-auth-token.outputs.token }} |
| 97 | + |
| 98 | + - name: Check Draft Issue |
| 99 | + uses: ./github-script/ |
| 100 | + with: |
| 101 | + script: | |
| 102 | + if ("${{ steps.get-draft-issue.outputs.title }}" !== "My Favorite Issue") { |
| 103 | + throw new Error("Draft issue title is not correct") |
| 104 | + } |
| 105 | +
|
| 106 | + const body = `${{ steps.get-draft-issue.outputs.body }}` |
| 107 | +
|
| 108 | + if (!body.includes("Here's another bar")) { |
| 109 | + throw new Error("Draft issue body is not correct") |
| 110 | + } |
| 111 | +
|
| 112 | + if ("${{ steps.get-draft-issue.outputs.field-value }}" != "Low") { |
| 113 | + throw new Error("Draft issue field is not correct") |
| 114 | + } |
| 115 | +
|
| 116 | + - name: Run Completed By |
| 117 | + uses: ./completed-by/ |
| 118 | + id: completed-by |
| 119 | + with: |
| 120 | + field-value: Done |
| 121 | + owner: ${{ steps.copy-project.outputs.owner }} |
| 122 | + project-number: ${{ steps.copy-project.outputs.number }} |
| 123 | + token: ${{ steps.get-auth-token.outputs.token }} |
| 124 | + |
| 125 | + - name: Check Draft Issue Is Completed |
| 126 | + uses: ./github-script/ |
| 127 | + with: |
| 128 | + script: | |
| 129 | + const item = await actions.getItem( |
| 130 | + "${{ steps.copy-project.outputs.owner }}", |
| 131 | + "${{ steps.copy-project.outputs.number }}", |
| 132 | + "${{ steps.get-draft-issue-id.outputs.id }}", |
| 133 | + "Status" |
| 134 | + ) |
| 135 | +
|
| 136 | + if (item.field?.value !== "Done") { |
| 137 | + throw new Error("Field value is not correct") |
| 138 | + } |
| 139 | + token: ${{ steps.get-auth-token.outputs.token }} |
| 140 | + |
| 141 | + - name: Add Item |
| 142 | + uses: ./add-item/ |
| 143 | + id: add-item |
| 144 | + with: |
| 145 | + content-url: https://github.com/dsanders11/project-actions/pull/2 |
| 146 | + field: Added |
| 147 | + field-value: ${{ steps.get-date.outputs.result }} |
| 148 | + owner: ${{ steps.copy-project.outputs.owner }} |
| 149 | + project-number: ${{ steps.copy-project.outputs.number }} |
| 150 | + token: ${{ steps.get-auth-token.outputs.token }} |
| 151 | + |
| 152 | + - name: Get Added Item |
| 153 | + uses: ./get-item/ |
| 154 | + id: get-added-item |
| 155 | + with: |
| 156 | + field: Added |
| 157 | + item: ${{ steps.add-item.outputs.id }} |
| 158 | + owner: ${{ steps.copy-project.outputs.owner }} |
| 159 | + project-number: ${{ steps.copy-project.outputs.number }} |
| 160 | + token: ${{ steps.get-auth-token.outputs.token }} |
| 161 | + |
| 162 | + - name: Check Added Item Field Value |
| 163 | + uses: ./github-script/ |
| 164 | + with: |
| 165 | + script: | |
| 166 | + if ("${{ steps.get-added-item.outputs.field-value }}" !== new Date("${{ steps.get-date.outputs.result }}").toISOString().split('T')[0]) { |
| 167 | + throw new Error("Field value is not correct") |
| 168 | + } |
| 169 | +
|
| 170 | + - name: Edit Item |
| 171 | + uses: ./edit-item/ |
| 172 | + id: edit-item |
| 173 | + with: |
| 174 | + field: Priority |
| 175 | + field-value: High |
| 176 | + item: ${{ steps.get-added-item.outputs.id }} |
| 177 | + owner: ${{ steps.copy-project.outputs.owner }} |
| 178 | + project-number: ${{ steps.copy-project.outputs.number }} |
| 179 | + token: ${{ steps.get-auth-token.outputs.token }} |
| 180 | + |
| 181 | + - name: Get Item |
| 182 | + uses: ./get-item/ |
| 183 | + id: get-edited-item |
| 184 | + with: |
| 185 | + field: Priority |
| 186 | + item: ${{ steps.edit-item.outputs.id }} |
| 187 | + owner: ${{ steps.copy-project.outputs.owner }} |
| 188 | + project-number: ${{ steps.copy-project.outputs.number }} |
| 189 | + token: ${{ steps.get-auth-token.outputs.token }} |
| 190 | + |
| 191 | + - name: Check Edited Item Field Value |
| 192 | + uses: ./github-script/ |
| 193 | + with: |
| 194 | + script: | |
| 195 | + if ("${{ steps.get-edited-item.outputs.field-value }}" !== "High") { |
| 196 | + throw new Error("Field value is not correct") |
| 197 | + } |
| 198 | +
|
| 199 | + - name: Test GitHub Script Action |
| 200 | + uses: ./github-script/ |
| 201 | + with: |
| 202 | + token: ${{ steps.get-auth-token.outputs.token }} |
| 203 | + script: | |
| 204 | + const item = await actions.getItem( |
| 205 | + "${{ steps.copy-project.outputs.owner }}", |
| 206 | + "${{ steps.copy-project.outputs.number }}", |
| 207 | + "${{ steps.edit-item.outputs.id }}", |
| 208 | + "Priority" |
| 209 | + ) |
| 210 | +
|
| 211 | + if (item.field?.value !== "High") { |
| 212 | + throw new Error("Field value is not correct") |
| 213 | + } |
| 214 | +
|
| 215 | + # - name: Archive Item |
| 216 | + # uses: ./archive-item/ |
| 217 | + # id: archive-item |
| 218 | + # with: |
| 219 | + # item: ${{ steps.add-item.outputs.id }} |
| 220 | + # owner: ${{ steps.copy-project.outputs.owner }} |
| 221 | + # project-number: ${{ steps.copy-project.outputs.number }} |
| 222 | + # token: ${{ steps.get-auth-token.outputs.token }} |
| 223 | + |
| 224 | + # - name: Unarchive Item |
| 225 | + # uses: ./archive-item/ |
| 226 | + # id: unarchive-item |
| 227 | + # with: |
| 228 | + # archived: false |
| 229 | + # item: ${{ steps.add-item.outputs.id }} |
| 230 | + # owner: ${{ steps.copy-project.outputs.owner }} |
| 231 | + # project-number: ${{ steps.copy-project.outputs.number }} |
| 232 | + # token: ${{ steps.get-auth-token.outputs.token }} |
| 233 | + |
| 234 | + - name: Delete Item |
| 235 | + uses: ./delete-item/ |
| 236 | + id: delete-item |
| 237 | + with: |
| 238 | + item: ${{ steps.edit-item.outputs.id }} |
| 239 | + owner: ${{ steps.copy-project.outputs.owner }} |
| 240 | + project-number: ${{ steps.copy-project.outputs.number }} |
| 241 | + token: ${{ steps.get-auth-token.outputs.token }} |
| 242 | + |
| 243 | + - name: Link Project to Repository |
| 244 | + uses: ./link-project/ |
| 245 | + if: ${{ matrix.owner == 'dsanders11' }} |
| 246 | + with: |
| 247 | + owner: ${{ steps.copy-project.outputs.owner }} |
| 248 | + project-number: ${{ steps.copy-project.outputs.number }} |
| 249 | + repository: dsanders11/project-actions |
| 250 | + token: ${{ steps.get-auth-token.outputs.token }} |
| 251 | + |
| 252 | + - name: Link Project to Team |
| 253 | + uses: ./link-project/ |
| 254 | + if: ${{ matrix.owner == 'dsanders11-playground-org' }} |
| 255 | + with: |
| 256 | + owner: ${{ steps.copy-project.outputs.owner }} |
| 257 | + project-number: ${{ steps.copy-project.outputs.number }} |
| 258 | + team: dsanders11-playground-org/maintainers |
| 259 | + token: ${{ steps.get-auth-token.outputs.token }} |
| 260 | + |
| 261 | + - name: Edit Project |
| 262 | + uses: ./edit-project/ |
| 263 | + id: edit-project |
| 264 | + with: |
| 265 | + description: New Description |
| 266 | + owner: ${{ steps.copy-project.outputs.owner }} |
| 267 | + project-number: ${{ steps.copy-project.outputs.number }} |
| 268 | + readme: This is the readme |
| 269 | + title: New Title |
| 270 | + token: ${{ steps.get-auth-token.outputs.token }} |
| 271 | + |
| 272 | + - name: Get Project |
| 273 | + uses: ./get-project/ |
| 274 | + id: get-project |
| 275 | + with: |
| 276 | + owner: ${{ steps.copy-project.outputs.owner }} |
| 277 | + project-number: ${{ steps.copy-project.outputs.number }} |
| 278 | + token: ${{ steps.get-auth-token.outputs.token }} |
| 279 | + |
| 280 | + - name: Check Project Values |
| 281 | + uses: ./github-script/ |
| 282 | + with: |
| 283 | + script: | |
| 284 | + if ("${{ steps.get-project.outputs.title }}" !== "New Title") { |
| 285 | + throw new Error("Project title is not correct") |
| 286 | + } |
| 287 | +
|
| 288 | + if ("${{ steps.get-project.outputs.description }}" !== "New Description") { |
| 289 | + throw new Error("Project description is not correct") |
| 290 | + } |
| 291 | +
|
| 292 | + if ("${{ steps.get-project.outputs.readme }}" !== "This is the readme") { |
| 293 | + throw new Error("Project readme is not correct") |
| 294 | + } |
| 295 | +
|
| 296 | + - name: Close Project |
| 297 | + uses: ./close-project/ |
| 298 | + id: close-project |
| 299 | + with: |
| 300 | + owner: ${{ steps.copy-project.outputs.owner }} |
| 301 | + project-number: ${{ steps.copy-project.outputs.number }} |
| 302 | + token: ${{ steps.get-auth-token.outputs.token }} |
| 303 | + |
| 304 | + - name: Reopen Project |
| 305 | + uses: ./close-project/ |
| 306 | + id: reopen-project |
| 307 | + with: |
| 308 | + closed: false |
| 309 | + owner: ${{ steps.copy-project.outputs.owner }} |
| 310 | + project-number: ${{ steps.copy-project.outputs.number }} |
| 311 | + token: ${{ steps.get-auth-token.outputs.token }} |
| 312 | + |
| 313 | + - name: Delete Project |
| 314 | + uses: ./delete-project/ |
| 315 | + id: delete-project |
| 316 | + with: |
| 317 | + owner: ${{ steps.copy-project.outputs.owner }} |
| 318 | + project-number: ${{ steps.copy-project.outputs.number }} |
| 319 | + token: ${{ steps.get-auth-token.outputs.token }} |
0 commit comments