|
| 1 | +name: Prebuild LLVM and Swift |
| 2 | +description: Builds the prebuilt package needed by the CodeQL Swift extractor |
| 3 | + |
| 4 | +runs: |
| 5 | + using: composite |
| 6 | + steps: |
| 7 | + ### Prepare |
| 8 | + - name: Send workflow telemetry to Datadog |
| 9 | + uses: masci/datadog@863b639c95138e957eb6e1e2499cecb82040a10b |
| 10 | + with: |
| 11 | + api-key: '${{ secrets.DATADOG_API_KEY }}' |
| 12 | + metrics: | |
| 13 | + - type: count |
| 14 | + name: codeql_ci_workflow.count |
| 15 | + value: 1 |
| 16 | + host: '${{ github.repository_owner }}' |
| 17 | + tags: |
| 18 | + - 'branch:${{ github.head_ref }}' |
| 19 | + - 'workflow:${{ github.workflow }}' |
| 20 | + - name: Workdir |
| 21 | + shell: bash |
| 22 | + run: | |
| 23 | + mkdir codeql-swift-prebuild |
| 24 | +
|
| 25 | + - name: Prepare (macOS) |
| 26 | + if: runner.os == 'macOS' |
| 27 | + shell: bash |
| 28 | + run: | |
| 29 | + brew install cmake |
| 30 | + pip install six |
| 31 | +
|
| 32 | + - name: Prepare (Linux) |
| 33 | + if: runner.os == 'Linux' |
| 34 | + shell: bash |
| 35 | + run: | |
| 36 | + sudo apt-get install -y cmake |
| 37 | +
|
| 38 | + ### For debugging |
| 39 | + |
| 40 | + - name: Dump environment |
| 41 | + shell: bash |
| 42 | + env: |
| 43 | + GITHUB_CONTEXT: '${{ toJson(github.event) }}' |
| 44 | + run: env | sort |
| 45 | + |
| 46 | + - run: uname -a |
| 47 | + shell: bash |
| 48 | + |
| 49 | + ### Build Swift |
| 50 | + |
| 51 | + - name: Copy preset |
| 52 | + working-directory: codeql-swift-prebuild |
| 53 | + bash: shell |
| 54 | + run: | |
| 55 | + cp codeql-swift-artifacts/swift-build-presets ~/.swift-build-presets |
| 56 | +
|
| 57 | + - name: Get swift version |
| 58 | + shell: bash |
| 59 | + run: | |
| 60 | + echo "SWIFT_TAG=$(cat codeql-swift-artifacts/swift_version.txt)" | tee -a $GITHUB_ENV |
| 61 | +
|
| 62 | + - name: Checkout Swift |
| 63 | + uses: actions/checkout@v3 |
| 64 | + with: |
| 65 | + repository: apple/swift |
| 66 | + path: swift |
| 67 | + ref: ${{ env.SWIFT_TAG }} |
| 68 | + |
| 69 | + - name: Checkout Swift dependencies |
| 70 | + working-directory: codeql-swift-prebuild |
| 71 | + shell: bash |
| 72 | + run: | |
| 73 | + swift/utils/update-checkout --clone --tag ${{ env.SWIFT_TAG }} |
| 74 | +
|
| 75 | + - name: Patch Swift |
| 76 | + working-directory: swift |
| 77 | + shell: bash |
| 78 | + run: | |
| 79 | + git apply $GITHUB_WORKSPACE/codeql-swift-artifacts/swift-build-system.patch |
| 80 | +
|
| 81 | + - uses: swift-actions/setup-swift@194625b58a582570f61cc707c3b558086c26b723 |
| 82 | + if: runner.os == 'Linux' |
| 83 | + with: |
| 84 | + swift-version: 5.7.1 |
| 85 | + |
| 86 | + - name: Build |
| 87 | + working-directory: codeql-swift-prebuild |
| 88 | + shell: bash |
| 89 | + env: |
| 90 | + SKIP_XCODE_VERSION_CHECK: 1 |
| 91 | + run: | |
| 92 | + swift/utils/build-script --preset=codeql |
| 93 | +
|
| 94 | + ### Package |
| 95 | + |
| 96 | + - name: Check build |
| 97 | + working-directory: codeql-swift-prebuild |
| 98 | + shell: bash |
| 99 | + run: | |
| 100 | + ls build |
| 101 | + ls build/codeql |
| 102 | +
|
| 103 | + - name: Package |
| 104 | + shell: bash |
| 105 | + working-directory: codeql-swift-prebuild |
| 106 | + run: | |
| 107 | + codeql-swift-artifacts/pkg_swift_llvm.py \ |
| 108 | + --swift-source-tree swift \ |
| 109 | + --llvm-build-tree build/codeql/llvm-* \ |
| 110 | + --swift-build-tree build/codeql/swift-* \ |
| 111 | + --output swift-prebuilt-${{ runner.os }}-${{ runner.arch }} |
| 112 | + ls |
| 113 | + file swift-prebuilt.* |
| 114 | +
|
| 115 | + ### Upload Artifacts |
| 116 | + |
| 117 | + - name: Upload pre-built artifacts |
| 118 | + uses: actions/upload-artifact@v3 |
| 119 | + with: |
| 120 | + name: swift-prebuilt-${{ runner.os }}-${{ runner.arch }} |
| 121 | + path: swift-prebuilt-* |
0 commit comments