github.com/metasources/buildx@v0.0.0-20230418141019-7aa1459cedea/.github/workflows/validations.yaml (about)

     1  name: "Validations"
     2  
     3  on:
     4    workflow_dispatch:
     5    pull_request:
     6    push:
     7      branches:
     8        - main
     9  
    10  jobs:
    11  
    12    Static-Analysis:
    13      # Note: changing this job name requires making the same update in the .github/workflows/release.yaml pipeline
    14      name: "Static analysis"
    15      runs-on: ubuntu-20.04
    16      steps:
    17        - uses: actions/checkout@v3
    18  
    19        - name: Bootstrap environment
    20          uses: ./.github/actions/bootstrap
    21  
    22        - name: Run static analysis
    23          run: make static-analysis
    24  
    25  
    26    Unit-Test:
    27      # Note: changing this job name requires making the same update in the .github/workflows/release.yaml pipeline
    28      name: "Unit tests"
    29      runs-on: ubuntu-20.04
    30      steps:
    31        - uses: actions/checkout@v3
    32  
    33        - name: Bootstrap environment
    34          uses: ./.github/actions/bootstrap
    35  
    36        - name: Restore Java test-fixture cache
    37          uses: actions/cache@v3
    38          with:
    39            path: buildx/pkg/cataloger/java/test-fixtures/java-builds/packages
    40            key: ${{ runner.os }}-unit-java-cache-${{ hashFiles( 'buildx/pkg/cataloger/java/test-fixtures/java-builds/packages.fingerprint' ) }}
    41  
    42        - name: Restore RPM test-fixture cache
    43          uses: actions/cache@v3
    44          with:
    45            path: buildx/pkg/cataloger/rpm/test-fixtures/rpms
    46            key: ${{ runner.os }}-unit-rpm-cache-${{ hashFiles( 'buildx/pkg/cataloger/rpm/test-fixtures/rpms.fingerprint' ) }}
    47  
    48        - name: Restore go binary test-fixture cache
    49          uses: actions/cache@v3
    50          with:
    51            path: buildx/pkg/cataloger/golang/test-fixtures/archs/binaries
    52            key: ${{ runner.os }}-unit-go-binaries-cache-${{ hashFiles( 'buildx/pkg/cataloger/golang/test-fixtures/archs/binaries.fingerprint' ) }}
    53  
    54        - name: Restore binary cataloger test-fixture cache
    55          uses: actions/cache@v3
    56          with:
    57            path: buildx/pkg/cataloger/binary/test-fixtures/classifiers/dynamic
    58            key: ${{ runner.os }}-unit-binary-cataloger-cache-${{ hashFiles( 'buildx/pkg/cataloger/binary/test-fixtures/cache.fingerprint' ) }}
    59  
    60        - name: Restore Kernel test-fixture cache
    61          uses: actions/cache@v3
    62          with:
    63            path: buildx/pkg/cataloger/kernel/test-fixtures/cache
    64            key: ${{ runner.os }}-unit-kernel-cache-${{ hashFiles( 'buildx/pkg/cataloger/kernel/test-fixtures/cache.fingerprint' ) }}
    65  
    66        - name: Run unit tests
    67          run: make unit
    68  
    69  
    70    Integration-Test:
    71      # Note: changing this job name requires making the same update in the .github/workflows/release.yaml pipeline
    72      name: "Integration tests"
    73      runs-on: ubuntu-20.04
    74      steps:
    75        - uses: actions/checkout@v3
    76  
    77        - name: Bootstrap environment
    78          uses: ./.github/actions/bootstrap
    79  
    80        - name: Validate buildx output against the CycloneDX schema
    81          run: make validate-cyclonedx-schema
    82  
    83        - name: Restore integration test cache
    84          uses: actions/cache@v3
    85          with:
    86            path: ${{ github.workspace }}/test/integration/test-fixtures/cache
    87            key: ${{ runner.os }}-integration-test-cache-${{ hashFiles('test/integration/test-fixtures/cache.fingerprint') }}
    88  
    89        - name: Run integration tests
    90          run: make integration
    91  
    92  
    93    Build-Snapshot-Artifacts:
    94      name: "Build snapshot artifacts"
    95      runs-on: ubuntu-20.04
    96      steps:
    97        - uses: actions/checkout@v3
    98  
    99        - name: Bootstrap environment
   100          uses: ./.github/actions/bootstrap
   101          with:
   102            # why have another build cache key? We don't want unit/integration/etc test build caches to replace
   103            # the snapshot build cache, which includes builds for all OSs and architectures. As long as this key is
   104            # unique from the build-cache-key-prefix in other CI jobs, we should be fine.
   105            #
   106            # note: ideally this value should match what is used in release (just to help with build times).
   107            build-cache-key-prefix: "snapshot"
   108            bootstrap-apt-packages: ""
   109  
   110        - name: Build snapshot artifacts
   111          run: make snapshot
   112  
   113        # why not use actions/upload-artifact? It is very slow (3 minutes to upload ~600MB of data, vs 10 seconds with this approach).
   114        # see https://github.com/actions/upload-artifact/issues/199 for more info
   115        - name: Upload snapshot artifacts
   116          uses: actions/cache/save@v3
   117          with:
   118            path: snapshot
   119            key: snapshot-build-${{ github.run_id }}
   120  
   121  
   122    Acceptance-Linux:
   123      # Note: changing this job name requires making the same update in the .github/workflows/release.yaml pipeline
   124      name: "Acceptance tests (Linux)"
   125      needs: [Build-Snapshot-Artifacts]
   126      runs-on: ubuntu-20.04
   127      steps:
   128        - uses: actions/checkout@v3
   129  
   130        - name: Download snapshot build
   131          uses: actions/cache/restore@v3
   132          with:
   133            path: snapshot
   134            key: snapshot-build-${{ github.run_id }}
   135  
   136        - name: Run comparison tests (Linux)
   137          run: make compare-linux
   138  
   139        - name: Restore install.sh test image cache
   140          id: install-test-image-cache
   141          uses: actions/cache@v3
   142          with:
   143            path: ${{ github.workspace }}/test/install/cache
   144            key: ${{ runner.os }}-install-test-image-cache-${{ hashFiles('test/install/cache.fingerprint') }}
   145  
   146        - name: Load test image cache
   147          if: steps.install-test-image-cache.outputs.cache-hit == 'true'
   148          run: make install-test-cache-load
   149  
   150        - name: Run install.sh tests (Linux)
   151          run: make install-test
   152  
   153        - name: (cache-miss) Create test image cache
   154          if: steps.install-test-image-cache.outputs.cache-hit != 'true'
   155          run: make install-test-cache-save
   156  
   157  
   158    Acceptance-Mac:
   159      # Note: changing this job name requires making the same update in the .github/workflows/release.yaml pipeline
   160      name: "Acceptance tests (Mac)"
   161      needs: [Build-Snapshot-Artifacts]
   162      runs-on: macos-latest
   163      steps:
   164        - uses: actions/checkout@v3
   165  
   166        - name: Download snapshot build
   167          uses: actions/cache/restore@v3
   168          with:
   169            path: snapshot
   170            key: snapshot-build-${{ github.run_id }}
   171  
   172        - name: Restore docker image cache for compare testing
   173          id: mac-compare-testing-cache
   174          uses: actions/cache@v3
   175          with:
   176            path: image.tar
   177            key: ${{ runner.os }}-${{ hashFiles('test/compare/mac.sh') }}
   178  
   179        - name: Run comparison tests (Mac)
   180          run: make compare-mac
   181  
   182        - name: Run install.sh tests (Mac)
   183          run: make install-test-ci-mac
   184  
   185  
   186    Cli-Linux:
   187      # Note: changing this job name requires making the same update in the .github/workflows/release.yaml pipeline
   188      name: "CLI tests (Linux)"
   189      needs: [Build-Snapshot-Artifacts]
   190      runs-on: ubuntu-20.04
   191      steps:
   192        - uses: actions/checkout@v3
   193  
   194        - name: Bootstrap environment
   195          uses: ./.github/actions/bootstrap
   196  
   197        - name: Restore CLI test-fixture cache
   198          uses: actions/cache@v3
   199          with:
   200            path: ${{ github.workspace }}/test/cli/test-fixtures/cache
   201            key: ${{ runner.os }}-cli-test-cache-${{ hashFiles('test/cli/test-fixtures/cache.fingerprint') }}
   202  
   203        - name: Download snapshot build
   204          uses: actions/cache/restore@v3
   205          with:
   206            path: snapshot
   207            key: snapshot-build-${{ github.run_id }}
   208  
   209        - name: Run CLI Tests (Linux)
   210          run: make cli