summaryrefslogtreecommitdiff
path: root/.github/workflows/ok-check.yml
blob: d7a9add914781fcdd022bc2fc06ed2248e7a04a9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
name: OK Check / Progress Push

on:
  pull_request:
    branches:
      - main
  push:
    branches:
      - main

env:
  GITHUB_ORG: "zeldaret"
  GITHUB_REPO: "tp"
  STATE_FILE: "tools/pjstate.yml"

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - name: Checkout
      uses: actions/checkout@v3
    - name: Project Setup
      run: |
        # Install deps & setup
        python3 -m pip install --user -r tools/requirements.txt
        ./tp setup --skip-iso

        # Download WiBo
        wget https://github.com/decompals/wibo/releases/download/0.4.2/wibo
        chmod +x wibo
    - name: Run Make (OK)
      run: make all rels -j$(nproc) WINE=./wibo
    - name: Create JSON for Progress & Upload
      if: github.event_name != 'pull_request'
      env: 
        PROGRESS_API_KEY: ${{ secrets.FROGRESS_API_KEY }}
      run: |
        ./tp progress -f JSON > progress-${{ github.run_id }}.json
        ./tp upload-progress progress-${{ github.run_id }}.json -b https://progress.deco.mp/ -p twilightprincess -v gcn_usa
    - name: Get changed .c, .cpp, .inc files
      if: github.event_name != 'pull_request'
      id: changed-files-specific
      uses: tj-actions/changed-files@v36
      with:
        files: |
          **/*.{c,cpp,inc}
    - name: Update Issue(s)
      if: github.event_name != 'pull_request' && steps.changed-files-specific.outputs.any_changed == 'true'
      run: |
        # Install libclang-16-dev for FunctionChecker
        wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
        sudo add-apt-repository "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-16 main"
        sudo apt update
        sudo apt install -y libclang-16-dev

        FILENAMES="${{ steps.changed-files-specific.outputs.all_changed_files }}"
        CMD=(./tp github-update-issues --personal-access-token ${{ secrets.PAT_TOKEN }} --debug --owner ${{ env.GITHUB_ORG }} --repo ${{ env.GITHUB_REPO }} --state-file ${{ env.STATE_FILE }})

        IFS=' ' read -ra FILE_ARRAY <<< "$FILENAMES"
        INC_FOUND=false

        # Remove any .inc files from the array
        for index in "${!FILE_ARRAY[@]}"; do
            if [[ "${FILE_ARRAY[index]}" == *.inc ]]; then
                unset 'FILE_ARRAY[index]'
                INC_FOUND=true
            fi
        done

        # If any .inc files were found,
        # We will add "src/d/a/d_a_alink.cpp" to the array once
        # if it's not already there
        if $INC_FOUND && ! [[ " ${FILE_ARRAY[@]} " =~ " src/d/a/d_a_alink.cpp " ]]; then
            FILE_ARRAY+=("src/d/a/d_a_alink.cpp")
        fi

        for FILE in "${FILE_ARRAY[@]}"; do
          AUTHOR=$(git log -1 --pretty=format:'%an' -- $FILE)
          CMD+=(--filename $FILE --author '$AUTHOR')
        done

        # Update the status and assignees for every issue identified
        # ${CMD[@]}