Compare app/src with public repository #7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Workflow to compare app/src folder with another public repository | |
| # This workflow is isolated and does NOT trigger builds for other workflows. | |
| # Parameters: target_repo_url, target_repo_branch | |
| # Ignores files in .gitignore and limits diff output to 100KB | |
| name: Compare app/src with public repository | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| target_repo_url: | |
| description: 'URL of the public repository to compare against' | |
| required: true | |
| type: string | |
| target_repo_branch: | |
| description: 'Branch of the public repository to compare against' | |
| required: true | |
| type: string | |
| workflow_call: | |
| inputs: {} | |
| jobs: | |
| check-gplv3-compliance: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Clone target repository | |
| run: | | |
| git clone --depth 1 --branch "${{ github.event.inputs.target_repo_branch }}" "${{ github.event.inputs.target_repo_url }}" targetrepo | |
| - name: Check for LICENSE file in target repository | |
| run: | | |
| if [ ! -f targetrepo/LICENSE ]; then | |
| echo "ERROR: LICENSE file not found in target repository." && exit 2 | |
| fi | |
| - name: Check for GPLv3 in LICENSE file | |
| run: | | |
| if ! grep -q "GNU General Public License" targetrepo/LICENSE || ! grep -q "Version 3" targetrepo/LICENSE; then | |
| echo "ERROR: LICENSE file does not contain GPLv3 text." && exit 3 | |
| fi | |
| - name: Check GPLv3 header in all .kt and .java files | |
| run: | | |
| missing_files=$(find targetrepo/app/src -type f \( -name '*.kt' -o -name '*.java' \) \ | |
| ! -exec grep -q 'GNU General Public License' {} \; -print) | |
| if [ -n "$missing_files" ]; then | |
| echo "ERROR: The following files are missing the GPLv3 header:" && echo "$missing_files" | |
| exit 4 | |
| fi | |
| compare-src: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout WiFiAnalyzer | |
| uses: actions/checkout@v4 | |
| with: | |
| path: wifianalyzer | |
| - name: Clone target repository | |
| run: | | |
| git clone --depth 1 --branch "${{ github.event.inputs.target_repo_branch }}" "${{ github.event.inputs.target_repo_url }}" targetrepo | |
| - name: Copy .gitignore from WiFiAnalyzer | |
| run: | | |
| cp wifianalyzer/.gitignore . | |
| - name: Prepare filtered app/src folders | |
| run: | | |
| mkdir filtered_wifianalyzer filtered_targetrepo | |
| rsync -av --exclude-from='.gitignore' wifianalyzer/app/src/ filtered_wifianalyzer/ | |
| rsync -av --exclude-from='.gitignore' targetrepo/app/src/ filtered_targetrepo/ | |
| - name: Compare app/src folders | |
| run: diff -r filtered_wifianalyzer filtered_targetrepo > diff_output.txt || true | |
| - name: Summarize file-level changes | |
| run: comm -3 <(find filtered_wifianalyzer -type f | sort) <(find filtered_targetrepo -type f | sort) > file_changes.txt | |
| - name: Upload diff and summary as artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: src-comparison | |
| path: | | |
| diff_output.txt | |
| file_changes.txt | |
| - name: Display summary in workflow output | |
| run: | | |
| echo "Summary of file-level changes:" && cat file_changes.txt | |
| echo "First 20 lines of diff output:" && head -20 diff_output.txt | |
| build-target-repo: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Clone target repository | |
| run: | | |
| git clone --depth 1 --branch "${{ github.event.inputs.target_repo_branch }}" "${{ github.event.inputs.target_repo_url }}" targetrepo | |
| - name: Make gradlew executable | |
| run: chmod +x targetrepo/gradlew | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '17' | |
| - name: Build target repository (assembleDebug) | |
| run: | | |
| cd targetrepo | |
| ./gradlew assembleDebug | |
| - name: Build target repository (assembleRelease) | |
| run: | | |
| cd targetrepo | |
| ./gradlew assembleRelease | |
| - name: Upload APKs if present | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: targetrepo-apks | |
| path: | | |
| targetrepo/app/build/outputs/apk/**/*.apk | |
| targetrepo/app/build/outputs/apk/*.apk |