|
| 1 | +name: Typescript Code Structure Graph Analysis |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + # Ignore changes in documentation, general configuration and reports for push events |
| 8 | + paths-ignore: |
| 9 | + - 'results/**' |
| 10 | + - '**/*.md' |
| 11 | + - '**/*.txt' |
| 12 | + - '**/*.css' |
| 13 | + - '**/*.html' |
| 14 | + - '**/*.js' |
| 15 | + - '.gitignore' |
| 16 | + - '.gitattributes' |
| 17 | + - 'renovate.json' |
| 18 | + - 'changelogTemplate.mustache' |
| 19 | + - '**.code-workspace' |
| 20 | + pull_request: |
| 21 | + branches: |
| 22 | + - main |
| 23 | + # Ignore changes in documentation, general configuration and reports for pull request events |
| 24 | + paths-ignore: |
| 25 | + - 'results/**' |
| 26 | + - '**/*.md' |
| 27 | + - '**/*.txt' |
| 28 | + - '**/*.css' |
| 29 | + - '**/*.html' |
| 30 | + - '**/*.js' |
| 31 | + - '.gitignore' |
| 32 | + - '.gitattributes' |
| 33 | + - 'renovate.json' |
| 34 | + - 'changelogTemplate.mustache' |
| 35 | + - '**.code-workspace' |
| 36 | + |
| 37 | +# Requires the secret NEO4J_INITIAL_PASSWORD to be configured |
| 38 | +jobs: |
| 39 | + reports: |
| 40 | + runs-on: ubuntu-latest |
| 41 | + strategy: |
| 42 | + matrix: |
| 43 | + include: |
| 44 | + - os: ubuntu-latest |
| 45 | + java: 17 |
| 46 | + python: 3.11 |
| 47 | + mambaforge: 24.3.0-0 |
| 48 | + node: 18 |
| 49 | + |
| 50 | + env: |
| 51 | + CI_COMMIT_MESSAGE: Automated code structure analysis reports (CI) |
| 52 | + CI_COMMIT_AUTHOR: ${{ github.event.repository.name }} Continuous Integration |
| 53 | + PROJECT_NAME: react-router |
| 54 | + # Version variable name matches renovate.json configuration entry |
| 55 | + REACT_ROUTER_VERSION: 6.22.0 |
| 56 | + |
| 57 | + steps: |
| 58 | + - name: Checkout GIT Repository |
| 59 | + uses: actions/checkout@v4 |
| 60 | + with: |
| 61 | + token: ${{ secrets.WORKFLOW_GIT_ACCESS_TOKEN }} |
| 62 | + |
| 63 | + - name: Setup Java JDK ${{ matrix.java }} |
| 64 | + uses: actions/setup-java@v4 |
| 65 | + with: |
| 66 | + distribution: 'adopt' |
| 67 | + java-version: ${{ matrix.java }} |
| 68 | + |
| 69 | + - name: Setup node.js ${{ matrix.node }} for Graph Visualization |
| 70 | + uses: actions/setup-node@v4 |
| 71 | + with: |
| 72 | + node-version: ${{ matrix.node }} |
| 73 | + |
| 74 | + - name: Install nodes packages for Graph Visualization |
| 75 | + working-directory: graph-visualization |
| 76 | + run: npm ci |
| 77 | + |
| 78 | + - name: Setup Cache for Conda package manager Mambaforge |
| 79 | + uses: actions/cache@v4 |
| 80 | + env: |
| 81 | + # Increase this value to reset cache if etc/example-environment.yml has not changed |
| 82 | + # Reference: https://github.com/conda-incubator/setup-miniconda#caching |
| 83 | + CACHE_NUMBER: 0 |
| 84 | + with: |
| 85 | + path: ~/conda_pkgs_dir |
| 86 | + key: |
| 87 | + ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-environments-${{hashFiles('**/environment.yml', '.github/workflows/*.yml') }} |
| 88 | + |
| 89 | + # "Setup Python" can be skipped if jupyter notebook reports aren't needed |
| 90 | + - name: Setup Python ${{ matrix.python }} with Conda package manager Mambaforge |
| 91 | + uses: conda-incubator/setup-miniconda@v3 |
| 92 | + with: |
| 93 | + python-version: ${{ matrix.python }} |
| 94 | + miniforge-variant: Mambaforge |
| 95 | + miniforge-version: ${{ matrix.mambaforge }} |
| 96 | + use-mamba: true |
| 97 | + activate-environment: codegraph |
| 98 | + environment-file: ./jupyter/environment.yml |
| 99 | + auto-activate-base: false |
| 100 | + use-only-tar-bz2: true # IMPORTANT: This needs to be set for caching to work properly! |
| 101 | + |
| 102 | + - name: Conda environment info |
| 103 | + shell: bash -el {0} |
| 104 | + run: conda info |
| 105 | + |
| 106 | + - name: Setup temp directory if missing |
| 107 | + run: mkdir -p ./temp |
| 108 | + |
| 109 | + - name: Setup Cache for "temp/downloads" folder |
| 110 | + uses: actions/cache@v4 |
| 111 | + with: |
| 112 | + path: ./temp/downloads |
| 113 | + key: |
| 114 | + ${{ runner.os }}-${{ hashFiles('**/*.sh') }} |
| 115 | + |
| 116 | + - name: Download ${{ env.PROJECT_NAME }}-${{ env.REACT_ROUTER_VERSION }} |
| 117 | + working-directory: temp |
| 118 | + run: | |
| 119 | + mkdir -p ${{ env.PROJECT_NAME }}-${{ env.REACT_ROUTER_VERSION }} |
| 120 | + cd ${{ env.PROJECT_NAME }}-${{ env.REACT_ROUTER_VERSION }} |
| 121 | + echo "Working directory: $( pwd -P )" |
| 122 | + ./../../scripts/downloader/downloadReactRouter.sh ${{ env.REACT_ROUTER_VERSION }} |
| 123 | +
|
| 124 | + - name: Analyze ${{ env.PROJECT_NAME }}-${{ env.REACT_ROUTER_VERSION }} |
| 125 | + working-directory: temp/${{ env.PROJECT_NAME }}-${{ env.REACT_ROUTER_VERSION }} |
| 126 | + # Shell type can be skipped if jupyter notebook reports (and therefore conda) aren't needed |
| 127 | + shell: bash -el {0} |
| 128 | + env: |
| 129 | + NEO4J_INITIAL_PASSWORD: ${{ secrets.NEO4J_INITIAL_PASSWORD }} |
| 130 | + ENABLE_JUPYTER_NOTEBOOK_PDF_GENERATION: "true" |
| 131 | + run: | |
| 132 | + ./../../scripts/analysis/analyze.sh |
| 133 | +
|
| 134 | + - name: Move reports from the temp to the results directory preserving their surrounding directory |
| 135 | + working-directory: temp |
| 136 | + run: ./../scripts/copyReportsIntoResults.sh |
| 137 | + |
| 138 | + # Upload logs and unfinished reports in case of an error for troubleshooting |
| 139 | + - name: Archive failed run with logs and unfinished results |
| 140 | + if: failure() |
| 141 | + uses: actions/upload-artifact@v4 |
| 142 | + with: |
| 143 | + name: code-analysis-logs-java-${{ matrix.java }}-python-${{ matrix.python }}-mambaforge-${{ matrix.mambaforge }} |
| 144 | + path: | |
| 145 | + ./temp/**/runtime/* |
| 146 | + ./temp/**/reports/* |
| 147 | + retention-days: 5 |
| 148 | + |
| 149 | + # Upload successful results in case they are needed for troubleshooting |
| 150 | + - name: Archive successful results |
| 151 | + if: success() |
| 152 | + uses: actions/upload-artifact@v4 |
| 153 | + with: |
| 154 | + name: code-report-results-java-${{ matrix.java }}-python-${{ matrix.python }}-mambaforge-${{ matrix.mambaforge }} |
| 155 | + path: ./results |
| 156 | + if-no-files-found: error |
| 157 | + retention-days: 5 |
| 158 | + |
| 159 | + # Upload Database Export |
| 160 | + # Only possible after an export with "./../../scripts/analysis/analyze.sh --report DatabaseCsvExport" |
| 161 | + # Won't be done here because of performance and security concerns |
| 162 | + #- name: Archive exported database |
| 163 | + # uses: actions/upload-artifact@v3 |
| 164 | + # with: |
| 165 | + # name: code-report-database-export-${{ matrix.java }}-python-${{ matrix.python }}-mambaforge-${{ matrix.mambaforge }} |
| 166 | + # path: ./temp/**/import |
| 167 | + # if-no-files-found: error |
| 168 | + # retention-days: 5 |
| 169 | + |
| 170 | + # Commit and push the native image agent results |
| 171 | + - name: Display environment variable "github.event_name" |
| 172 | + run: echo "github.event_name=${{ github.event_name }}" |
| 173 | + - name: Commit "results" directory containing the reports |
| 174 | + # Only run when a pull request gets merged or a commit is pushed to the main branch |
| 175 | + # git add parameters need to match paths-ignore parameters above |
| 176 | + # Git pull before add/commit/push to reduce race conditions on parallel builds |
| 177 | + if: github.event_name == 'push' |
| 178 | + run: | |
| 179 | + git config --global user.name '${{ env.CI_COMMIT_AUTHOR }}' |
| 180 | + git config --global user.email '[email protected]' |
| 181 | + git config --local http.postBuffer 524288000 |
| 182 | + git pull |
| 183 | + git add results |
| 184 | + git commit -m "${{ env.CI_COMMIT_MESSAGE }}" |
| 185 | + git push |
0 commit comments