github.com/minio/console@v1.3.0/.github/workflows/jobs.yaml (about)

     1  # @format
     2  
     3  name: Workflow
     4  
     5  on:
     6    pull_request:
     7      branches:
     8        - master
     9    push:
    10      branches:
    11        - master
    12  
    13  # This ensures that previous jobs for the PR are canceled when the PR is
    14  # updated.
    15  concurrency:
    16    group: ${{ github.workflow }}-${{ github.head_ref }}
    17    cancel-in-progress: true
    18  
    19  jobs:
    20    lint-job:
    21      name: Checking Lint
    22      runs-on: [ ubuntu-latest ]
    23      strategy:
    24        matrix:
    25          go-version: [ 1.21.x ]
    26          os: [ ubuntu-latest ]
    27      steps:
    28        - name: Check out code
    29          uses: actions/checkout@v3
    30  
    31        - name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
    32          uses: actions/setup-go@v3
    33          with:
    34            go-version: ${{ matrix.go-version }}
    35            cache: true
    36          id: go
    37  
    38        - name: Build on ${{ matrix.os }}
    39          env:
    40            GO111MODULE: on
    41            GOOS: linux
    42          run: |
    43            make verifiers
    44  
    45    semgrep-static-code-analysis:
    46      name: "semgrep checks"
    47      runs-on: ubuntu-latest
    48      strategy:
    49        matrix:
    50          os: [ ubuntu-latest ]
    51      steps:
    52        - name: Check out source code
    53          uses: actions/checkout@v3
    54        - name: Scanning code on ${{ matrix.os }}
    55          continue-on-error: false
    56          run: |
    57            # Install semgrep rather than using a container due to:
    58            # https://github.com/actions/checkout/issues/334
    59            sudo apt install -y python3-pip || apt install -y python3-pip
    60            pip3 install semgrep
    61            semgrep --config semgrep.yaml $(pwd)/web-app --error
    62  
    63    ui-assets:
    64      name: "React Code Has No Warnings & Prettified"
    65      runs-on: ubuntu-latest
    66      strategy:
    67        matrix:
    68          go-version: [ 1.21.x ]
    69          os: [ ubuntu-latest ]
    70      steps:
    71        - name: Check out code
    72          uses: actions/checkout@v3
    73        - name: Read .nvmrc
    74          id: node_version
    75          run: echo "$(cat .nvmrc)" && echo "NVMRC=$(cat .nvmrc)" >> $GITHUB_ENV
    76        - uses: actions/setup-node@v3
    77          with:
    78            node-version: ${{ env.NVMRC }}
    79            cache: "yarn"
    80            cache-dependency-path: web-app/yarn.lock
    81        - uses: actions/cache@v3
    82          id: assets-cache
    83          name: Assets Cache
    84          with:
    85            path: |
    86              ./web-app/build/
    87            key: ${{ runner.os }}-assets-${{ github.run_id }}
    88        - name: Install Dependencies
    89          working-directory: ./web-app
    90          continue-on-error: false
    91          run: |
    92            yarn install --frozen-lockfile --immutable
    93        - name: Check for Warnings in build output
    94          working-directory: ./web-app
    95          continue-on-error: false
    96          run: |
    97            ./check-warnings.sh
    98        - name: Check if Files are Prettified
    99          working-directory: ./web-app
   100          continue-on-error: false
   101          run: |
   102            ./check-prettier.sh
   103        - name: Check for dead code
   104          working-directory: ./web-app
   105          continue-on-error: false
   106          run: |
   107            ./check-deadcode.sh
   108    reuse-golang-dependencies:
   109      name: reuse golang dependencies
   110      runs-on: ubuntu-latest
   111      strategy:
   112        matrix:
   113          go-version: [ 1.21.x ]
   114          os: [ ubuntu-latest ]
   115      steps:
   116        - name: Check out code
   117          uses: actions/checkout@v3
   118        - name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
   119          uses: actions/setup-go@v3
   120          with:
   121            go-version: ${{ matrix.go-version }}
   122            cache: true
   123          id: go
   124        - name: Build on ${{ matrix.os }}
   125          env:
   126            GO111MODULE: on
   127            GOOS: linux
   128          run: |
   129            go mod download
   130  
   131    latest-minio:
   132      name: Build latest MinIO
   133      runs-on: [ ubuntu-latest ]
   134      strategy:
   135        matrix:
   136          go-version: [ 1.21.x ]
   137      steps:
   138        # To build minio image, we need to clone the repository first
   139        - name: Clone github.com/minio/minio
   140          uses: actions/checkout@v3
   141          with:
   142            repository: minio/minio
   143        - uses: actions/cache@v3
   144          id: minio-latest-cache
   145          name: MinIO Latest Cache
   146          with:
   147            path: |
   148              ./minio
   149            key: ${{ runner.os }}-minio-latest-${{ hashFiles('./go.sum') }}
   150        - name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
   151          uses: actions/setup-go@v3
   152          with:
   153            go-version: ${{ matrix.go-version }}
   154            cache: true
   155          id: go-minio
   156        - name: Build on ${{ matrix.os }}
   157          if: steps.minio-latest-cache.outputs.cache-hit != 'true'
   158          run: |
   159            echo "Create minio binary";
   160            make build;
   161    compile-binary:
   162      name: Compiles on Go ${{ matrix.go-version }} and ${{ matrix.os }}
   163      needs:
   164        - lint-job
   165        - ui-assets
   166        - reuse-golang-dependencies
   167        - semgrep-static-code-analysis
   168      runs-on: ${{ matrix.os }}
   169      strategy:
   170        matrix:
   171          go-version: [ 1.21.x ]
   172          os: [ ubuntu-latest ]
   173      steps:
   174        - name: Check out code
   175          uses: actions/checkout@v3
   176  
   177        - name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
   178          uses: actions/setup-go@v3
   179          with:
   180            go-version: ${{ matrix.go-version }}
   181            cache: true
   182          id: go
   183        - uses: actions/cache@v3
   184          name: Console Binary Cache
   185          with:
   186            path: |
   187              ./console
   188            key: ${{ runner.os }}-binary-${{ github.run_id }}
   189        - uses: actions/cache@v3
   190          id: assets-cache
   191          name: Assets Cache
   192          with:
   193            path: |
   194              ./web-app/build/
   195            key: ${{ runner.os }}-assets-${{ github.run_id }}
   196        - name: Build on ${{ matrix.os }}
   197          env:
   198            GO111MODULE: on
   199            GOOS: linux
   200          run: |
   201            make console
   202  
   203    test-nginx-subpath:
   204      name: Test Subpath with Nginx
   205      needs:
   206        - compile-binary
   207      runs-on: [ ubuntu-latest ]
   208      timeout-minutes: 10
   209      strategy:
   210        matrix:
   211          go-version: [ 1.21.x ]
   212          os: [ ubuntu-latest ]
   213      steps:
   214        - name: Check out code
   215          uses: actions/checkout@v3
   216        - uses: actions/setup-node@v3
   217          with:
   218            node-version: ${{ env.NVMRC }}
   219        - name: Install MinIO JS
   220          working-directory: ./
   221          continue-on-error: false
   222          run: |
   223            yarn add minio
   224  
   225        - uses: actions/cache@v3
   226          name: Console Binary Cache
   227          with:
   228            path: |
   229              ./console
   230            key: ${{ runner.os }}-binary-${{ github.run_id }}
   231  
   232        - name: clean-previous-containers-if-any
   233          run: |
   234            docker stop minio || true;
   235            docker container prune -f || true;
   236  
   237        - name: Start Console, MinIO and Nginx
   238          run: |
   239            (CONSOLE_SUBPATH=/console/subpath ./console server ) & (make test-initialize-minio-nginx)
   240  
   241        - name: Install TestCafe
   242          run: npm install testcafe@3.0.0
   243  
   244        - name: Run TestCafe Tests
   245          run: npx testcafe "chrome:headless" web-app/tests/subpath-nginx/ -q --skip-js-errors -c 3
   246  
   247        - name: Clean up docker
   248          if: always()
   249          run: |
   250            make cleanup-minio-nginx
   251  
   252    all-permissions-1:
   253      name: Permissions Tests Part 1
   254      needs:
   255        - compile-binary
   256      runs-on: [ ubuntu-latest ]
   257      timeout-minutes: 10
   258      strategy:
   259        matrix:
   260          go-version: [ 1.21.x ]
   261          os: [ ubuntu-latest ]
   262      steps:
   263        - name: Check out code
   264          uses: actions/checkout@v3
   265        - uses: actions/setup-node@v3
   266          with:
   267            node-version: ${{ env.NVMRC }}
   268        - name: Install MinIO JS
   269          working-directory: ./
   270          continue-on-error: false
   271          run: |
   272            yarn add minio
   273  
   274        - uses: actions/cache@v3
   275          name: Console Binary Cache
   276          with:
   277            path: |
   278              ./console
   279            key: ${{ runner.os }}-binary-${{ github.run_id }}
   280  
   281        - name: clean-previous-containers-if-any
   282          run: |
   283            docker stop minio || true;
   284            docker container prune -f || true;
   285  
   286        - name: Start Console, front-end app and initialize users/policies
   287          run: |
   288            (./console server) & (make initialize-permissions)
   289  
   290        - name: Install TestCafe
   291          run: npm install testcafe@3.0.0
   292  
   293        - name: Run TestCafe Tests
   294          run: npx testcafe "chrome:headless" web-app/tests/permissions-1/ -q --skip-js-errors -c 3
   295  
   296        - name: Clean up users & policies
   297          run: |
   298            make cleanup-permissions
   299  
   300    all-permissions-2:
   301      name: Permissions Tests Part 2
   302      needs:
   303        - compile-binary
   304      runs-on: [ ubuntu-latest ]
   305      timeout-minutes: 10
   306      strategy:
   307        matrix:
   308          go-version: [ 1.21.x ]
   309          os: [ ubuntu-latest ]
   310      steps:
   311        - name: Check out code
   312          uses: actions/checkout@v3
   313        - uses: actions/setup-node@v3
   314          with:
   315            node-version: ${{ env.NVMRC }}
   316        - name: Install MinIO JS
   317          working-directory: ./
   318          continue-on-error: false
   319          run: |
   320            yarn add minio
   321        - uses: actions/cache@v3
   322          name: Console Binary Cache
   323          with:
   324            path: |
   325              ./console
   326            key: ${{ runner.os }}-binary-${{ github.run_id }}
   327  
   328        - name: clean-previous-containers-if-any
   329          run: |
   330            docker stop minio || true;
   331            docker container prune -f || true;
   332  
   333        - name: Start Console, front-end app and initialize users/policies
   334          run: |
   335            (./console server) & (make initialize-permissions)
   336  
   337        - name: Install TestCafe
   338          run: npm install testcafe@3.0.0
   339  
   340        - name: Run TestCafe Tests
   341          run: npx testcafe "chrome:headless" web-app/tests/permissions-2/ -q --skip-js-errors -c 3
   342  
   343        - name: Clean up users & policies
   344          run: |
   345            make cleanup-permissions
   346  
   347    all-permissions-3:
   348      name: Permissions Tests Part 3
   349      needs:
   350        - compile-binary
   351      runs-on: [ ubuntu-latest ]
   352      timeout-minutes: 10
   353      strategy:
   354        matrix:
   355          go-version: [ 1.21.x ]
   356          os: [ ubuntu-latest ]
   357      steps:
   358        - name: Check out code
   359          uses: actions/checkout@v3
   360        - uses: actions/setup-node@v3
   361          with:
   362            node-version: ${{ env.NVMRC }}
   363        - name: Install MinIO JS
   364          working-directory: ./
   365          continue-on-error: false
   366          run: |
   367            yarn add minio
   368        - uses: actions/cache@v3
   369          name: Console Binary Cache
   370          with:
   371            path: |
   372              ./console
   373            key: ${{ runner.os }}-binary-${{ github.run_id }}
   374  
   375        - name: clean-previous-containers-if-any
   376          run: |
   377            docker stop minio || true;
   378            docker container prune -f || true;
   379  
   380        - name: Start Console, front-end app and initialize users/policies
   381          run: |
   382            (./console server) & (make initialize-permissions)
   383  
   384        - name: Install TestCafe
   385          run: npm install testcafe@3.0.0
   386  
   387        - name: Run TestCafe Tests
   388          run: npx testcafe "chrome:headless" web-app/tests/permissions-3/ -q --skip-js-errors -c 3
   389  
   390        - name: Clean up users & policies
   391          run: |
   392            make cleanup-permissions
   393  
   394    all-permissions-4:
   395      name: Permissions Tests Part 4
   396      needs:
   397        - compile-binary
   398      runs-on: [ ubuntu-latest ]
   399      timeout-minutes: 15
   400      strategy:
   401        matrix:
   402          go-version: [ 1.21.x ]
   403          os: [ ubuntu-latest ]
   404      steps:
   405        - name: Check out code
   406          uses: actions/checkout@v3
   407        - uses: actions/setup-node@v3
   408          with:
   409            node-version: ${{ env.NVMRC }}
   410        - name: Install MinIO JS
   411          working-directory: ./
   412          continue-on-error: false
   413          run: |
   414            yarn add minio
   415        - uses: actions/cache@v3
   416          name: Console Binary Cache
   417          with:
   418            path: |
   419              ./console
   420            key: ${{ runner.os }}-binary-${{ github.run_id }}
   421  
   422        - name: clean-previous-containers-if-any
   423          run: |
   424            docker stop minio || true;
   425            docker container prune -f || true;
   426  
   427        - name: Start Console, front-end app and initialize users/policies
   428          run: |
   429            (./console server) & (make initialize-permissions)
   430  
   431        - name: Install TestCafe
   432          run: npm install testcafe@3.0.0
   433  
   434        - name: Run TestCafe Tests
   435          timeout-minutes: 10
   436          run: npx testcafe "chrome:headless" web-app/tests/permissions-4/ --skip-js-errors
   437  
   438    all-permissions-5:
   439      name: Permissions Tests Part 5
   440      needs:
   441        - compile-binary
   442      runs-on: [ ubuntu-latest ]
   443      strategy:
   444        matrix:
   445          go-version: [ 1.21.x ]
   446          os: [ ubuntu-latest ]
   447      steps:
   448        - name: Check out code
   449          uses: actions/checkout@v3
   450        - uses: actions/setup-node@v3
   451          with:
   452            node-version: ${{ env.NVMRC }}
   453        - name: Install MinIO JS
   454          working-directory: ./
   455          continue-on-error: false
   456          run: |
   457            yarn add minio
   458        - uses: actions/cache@v3
   459          name: Console Binary Cache
   460          with:
   461            path: |
   462              ./console
   463            key: ${{ runner.os }}-binary-${{ github.run_id }}
   464  
   465        - name: clean-previous-containers-if-any
   466          run: |
   467            docker stop minio || true;
   468            docker container prune -f || true;
   469  
   470        - name: Start Console, front-end app and initialize users/policies
   471          run: |
   472            (./console server) & (make initialize-permissions)
   473  
   474        - name: Install TestCafe
   475          run: npm install testcafe@3.0.0
   476  
   477        - name: Run TestCafe Tests
   478          timeout-minutes: 5
   479          run: npx testcafe "chrome:headless" web-app/tests/permissions-5/ --skip-js-errors
   480  
   481    all-permissions-6:
   482      name: Permissions Tests Part 6
   483      needs:
   484        - compile-binary
   485      runs-on: [ ubuntu-latest ]
   486      strategy:
   487        matrix:
   488          go-version: [ 1.21.x ]
   489          os: [ ubuntu-latest ]
   490      steps:
   491        - name: Check out code
   492          uses: actions/checkout@v3
   493        - uses: actions/setup-node@v3
   494          with:
   495            node-version: ${{ env.NVMRC }}
   496        - name: Install MinIO JS
   497          working-directory: ./
   498          continue-on-error: false
   499          run: |
   500            yarn add minio
   501        - uses: actions/cache@v3
   502          name: Console Binary Cache
   503          with:
   504            path: |
   505              ./console
   506            key: ${{ runner.os }}-binary-${{ github.run_id }}
   507  
   508        - name: clean-previous-containers-if-any
   509          run: |
   510            docker stop minio || true;
   511            docker container prune -f || true;
   512  
   513        - name: Start Console, front-end app and initialize users/policies
   514          run: |
   515            (./console server) & (make initialize-permissions)
   516  
   517        - name: Install TestCafe
   518          run: npm install testcafe@3.0.0
   519  
   520        - name: Run TestCafe Tests
   521          timeout-minutes: 5
   522          run: npx testcafe "chrome:headless" web-app/tests/permissions-6/ --skip-js-errors
   523  
   524    all-permissions-7:
   525      name: Permissions Tests Part 7
   526      needs:
   527        - compile-binary
   528      runs-on: [ ubuntu-latest ]
   529      strategy:
   530        matrix:
   531          go-version: [ 1.21.x ]
   532          os: [ ubuntu-latest ]
   533      steps:
   534        - name: Check out code
   535          uses: actions/checkout@v3
   536        - uses: actions/setup-node@v3
   537          with:
   538            node-version: ${{ env.NVMRC }}
   539        - name: Install MinIO JS
   540          working-directory: ./
   541          continue-on-error: false
   542          run: |
   543            yarn add minio
   544        - uses: actions/cache@v3
   545          name: Console Binary Cache
   546          with:
   547            path: |
   548              ./console
   549            key: ${{ runner.os }}-binary-${{ github.run_id }}
   550  
   551        - name: clean-previous-containers-if-any
   552          run: |
   553            docker stop minio || true;
   554            docker container prune -f || true;
   555  
   556        - name: Start Console, front-end app and initialize users/policies
   557          run: |
   558            (./console server) & (make initialize-permissions)
   559        - name: Install TestCafe
   560          run: npm install testcafe@3.0.0
   561  
   562        - name: Run TestCafe Tests
   563          timeout-minutes: 5
   564          run: npx testcafe "chrome:headless" web-app/tests/permissions-7/ --skip-js-errors
   565  
   566    all-permissions-8:
   567      name: Permissions Tests Part 8
   568      needs:
   569        - compile-binary
   570      runs-on: [ ubuntu-latest ]
   571      strategy:
   572        matrix:
   573          go-version: [ 1.21.x ]
   574          os: [ ubuntu-latest ]
   575      steps:
   576        - name: Check out code
   577          uses: actions/checkout@v3
   578        - uses: actions/setup-node@v3
   579          with:
   580            node-version: ${{ env.NVMRC }}
   581        - name: Install MinIO JS
   582          working-directory: ./
   583          continue-on-error: false
   584          run: |
   585            yarn add minio
   586        - uses: actions/cache@v3
   587          name: Console Binary Cache
   588          with:
   589            path: |
   590              ./console
   591            key: ${{ runner.os }}-binary-${{ github.run_id }}
   592  
   593        - name: clean-previous-containers-if-any
   594          run: |
   595            docker stop minio || true;
   596            docker container prune -f || true;
   597  
   598        - name: Start Console, front-end app and initialize users/policies
   599          run: |
   600            (./console server) & (make initialize-permissions)
   601  
   602        - name: Install TestCafe
   603          run: npm install testcafe@3.0.0
   604  
   605        - name: Run TestCafe Tests
   606          timeout-minutes: 5
   607          run: npx testcafe "chrome:headless" web-app/tests/permissions-8/ --skip-js-errors
   608  
   609    all-permissions-A:
   610      name: Permissions Tests Part A
   611      needs:
   612        - compile-binary
   613      runs-on: [ ubuntu-latest ]
   614      strategy:
   615        matrix:
   616          go-version: [ 1.21.x ]
   617          os: [ ubuntu-latest ]
   618      steps:
   619        - name: Check out code
   620          uses: actions/checkout@v3
   621        - uses: actions/setup-node@v3
   622          with:
   623            node-version: ${{ env.NVMRC }}
   624        - name: Install MinIO JS
   625          working-directory: ./
   626          continue-on-error: false
   627          run: |
   628            yarn add minio
   629        - uses: actions/cache@v3
   630          name: Console Binary Cache
   631          with:
   632            path: |
   633              ./console
   634            key: ${{ runner.os }}-binary-${{ github.run_id }}
   635  
   636        - name: clean-previous-containers-if-any
   637          run: |
   638            docker stop minio || true;
   639            docker container prune -f || true;
   640  
   641        - name: Start Console, front-end app and initialize users/policies
   642          run: |
   643            (./console server) & (make initialize-permissions)
   644  
   645        - name: Install TestCafe
   646          run: npm install testcafe@3.0.0
   647  
   648        - name: Run TestCafe Tests
   649          run: npx testcafe "chrome:headless" web-app/tests/permissions-A/ --skip-js-errors -c 3
   650  
   651        - name: Clean up users & policies
   652          run: |
   653            make cleanup-permissions
   654  
   655    all-permissions-B:
   656      name: Permissions Tests Part B
   657      needs:
   658        - compile-binary
   659      runs-on: [ ubuntu-latest ]
   660      strategy:
   661        matrix:
   662          go-version: [ 1.21.x ]
   663          os: [ ubuntu-latest ]
   664      steps:
   665        - name: Check out code
   666          uses: actions/checkout@v3
   667        - uses: actions/setup-node@v3
   668          with:
   669            node-version: ${{ env.NVMRC }}
   670        - name: Install MinIO JS
   671          working-directory: ./
   672          continue-on-error: false
   673          run: |
   674            yarn add minio
   675        - uses: actions/cache@v3
   676          name: Console Binary Cache
   677          with:
   678            path: |
   679              ./console
   680            key: ${{ runner.os }}-binary-${{ github.run_id }}
   681  
   682        - name: clean-previous-containers-if-any
   683          run: |
   684            docker stop minio || true;
   685            docker container prune -f || true;
   686  
   687        - name: Start Console, front-end app and initialize users/policies
   688          run: |
   689            (./console server) & (make initialize-permissions)
   690  
   691        - name: Install TestCafe
   692          run: npm install testcafe@3.0.0
   693  
   694        - name: Run TestCafe Tests
   695          run: npx testcafe "chrome:headless" web-app/tests/permissions-B/ --skip-js-errors -c 3
   696  
   697        - name: Clean up users & policies
   698          run: |
   699            make cleanup-permissions
   700  
   701    test-pkg-on-go:
   702      name: Test Pkg on Go ${{ matrix.go-version }} and ${{ matrix.os }}
   703      needs:
   704        - lint-job
   705        - ui-assets
   706        - reuse-golang-dependencies
   707        - semgrep-static-code-analysis
   708      runs-on: ${{ matrix.os }}
   709      strategy:
   710        matrix:
   711          go-version: [ 1.21.x ]
   712          os: [ ubuntu-latest ]
   713      steps:
   714        - name: Check out code
   715          uses: actions/checkout@v3
   716  
   717        - name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
   718          uses: actions/setup-go@v3
   719          with:
   720            go-version: ${{ matrix.go-version }}
   721            cache: true
   722          id: go
   723  
   724        - name: Build on ${{ matrix.os }}
   725          env:
   726            GO111MODULE: on
   727            GOOS: linux
   728          run: |
   729            make test-pkg
   730  
   731        - uses: actions/cache@v3
   732          id: coverage-cache-pkg
   733          name: Coverage Cache Pkg
   734          with:
   735            path: |
   736              ./pkg/coverage/
   737            key: ${{ runner.os }}-coverage-pkg-2-${{ github.run_id }}
   738    test-api-on-go:
   739      name: Test API on Go ${{ matrix.go-version }} and ${{ matrix.os }}
   740      needs:
   741        - lint-job
   742        - ui-assets
   743        - reuse-golang-dependencies
   744        - semgrep-static-code-analysis
   745      runs-on: ${{ matrix.os }}
   746      strategy:
   747        matrix:
   748          go-version: [ 1.21.x ]
   749          os: [ ubuntu-latest ]
   750      steps:
   751        - name: Check out code
   752          uses: actions/checkout@v3
   753  
   754        - name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
   755          uses: actions/setup-go@v3
   756          with:
   757            go-version: ${{ matrix.go-version }}
   758            cache: true
   759          id: go
   760  
   761        - name: Build on ${{ matrix.os }}
   762          env:
   763            GO111MODULE: on
   764            GOOS: linux
   765          run: |
   766            make test
   767  
   768        - uses: actions/cache@v3
   769          id: coverage-cache-api
   770          name: Coverage Cache API
   771          with:
   772            path: |
   773              ./api/coverage/
   774            key: ${{ runner.os }}-coverage-api-2-${{ github.run_id }}
   775    b-integration-tests:
   776      name: Integration Tests with Latest Distributed MinIO
   777      needs:
   778        - lint-job
   779        - ui-assets
   780        - reuse-golang-dependencies
   781        - semgrep-static-code-analysis
   782        - latest-minio
   783      runs-on: ubuntu-latest
   784  
   785      strategy:
   786        matrix:
   787          go-version: [ 1.21.x ]
   788  
   789      steps:
   790        - name: Check out code
   791          uses: actions/checkout@v3
   792        - name: Clone github.com/minio/minio
   793          uses: actions/checkout@master
   794          with:
   795            repository: minio/minio
   796            path: "minio_repository"
   797        - uses: actions/cache@v3
   798          id: minio-latest-cache
   799          name: MinIO Latest Cache
   800          with:
   801            path: |
   802              ./minio
   803            key: ${{ runner.os }}-minio-latest-${{ hashFiles('./minio_repository/go.sum') }}
   804        - name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
   805          uses: actions/setup-go@v3
   806          with:
   807            go-version: ${{ matrix.go-version }}
   808            cache: true
   809          id: go
   810  
   811        - name: Build on ${{ matrix.os }}
   812          run: |
   813            echo "The idea is to build minio image from downloaded repository";
   814            cd $GITHUB_WORKSPACE/minio_repository;
   815            echo "Get git version to build MinIO Image";
   816            VERSION=`git rev-parse HEAD`;
   817            echo $VERSION;
   818            echo "Create MinIO image";
   819            if [ ! -f ../minio ]; then
   820                echo "minio binary not found!, so compiling..."
   821                make docker VERSION=$VERSION;
   822            else
   823                echo "Using binary from cache"
   824                cp ../minio .
   825            fi
   826            docker build -q --no-cache -t minio/minio:$VERSION . -f Dockerfile
   827            echo "Jumping back to console repository to run the integration test"
   828            cd $GITHUB_WORKSPACE;
   829            echo "We are going to use the built image on test-integration";
   830            VERSION="minio/minio:$VERSION";
   831            echo $VERSION;
   832  
   833            echo "Create bucket for replication with versioning"
   834            echo "Download mc for Ubuntu"
   835            wget -q https://dl.min.io/client/mc/release/linux-amd64/mc
   836            echo "Change the permissions to execute mc command"
   837            chmod +x mc
   838            echo "Create the folder to put the all.out file"
   839            make test-integration MINIO_VERSION=$VERSION;
   840  
   841        - uses: actions/cache@v3
   842          id: coverage-cache
   843          name: Coverage Cache
   844          with:
   845            path: |
   846              ./integration/coverage/
   847            key: ${{ runner.os }}-coverage-2-${{ github.run_id }}
   848    react-tests:
   849      name: React Tests
   850      needs:
   851        - lint-job
   852        - ui-assets
   853        - reuse-golang-dependencies
   854        - semgrep-static-code-analysis
   855      runs-on: ubuntu-latest
   856      steps:
   857        - uses: actions/checkout@v3
   858        - name: Install modules
   859          working-directory: ./web-app
   860          run: yarn
   861        - name: Run tests
   862          working-directory: ./web-app
   863          run: yarn test
   864    replication:
   865      name: Site Replication Test
   866      needs:
   867        - lint-job
   868        - ui-assets
   869        - reuse-golang-dependencies
   870        - semgrep-static-code-analysis
   871        - latest-minio
   872      runs-on: [ ubuntu-latest ]
   873  
   874      strategy:
   875        matrix:
   876          go-version: [ 1.21.x ]
   877  
   878      steps:
   879        - name: Check out code
   880          uses: actions/checkout@v3
   881  
   882        - name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
   883          uses: actions/setup-go@v3
   884          with:
   885            go-version: ${{ matrix.go-version }}
   886            cache: true
   887          id: go
   888  
   889        - name: Clone github.com/minio/minio
   890          uses: actions/checkout@master
   891          with:
   892            repository: minio/minio
   893            path: "minio_repository"
   894        - uses: actions/cache@v3
   895          id: minio-latest-cache
   896          name: MinIO Latest Cache
   897          with:
   898            path: |
   899              ./minio
   900            key: ${{ runner.os }}-minio-latest-${{ hashFiles('./minio_repository/go.sum') }}
   901  
   902        - name: Build on ${{ matrix.os }}
   903          run: |
   904            echo "The idea is to build minio image from downloaded repository";
   905            cd $GITHUB_WORKSPACE/minio_repository;
   906            echo "Get git version to build MinIO Image";
   907            VERSION=`git rev-parse HEAD`;
   908            echo $VERSION;
   909            echo "Create MinIO image";
   910            if [ ! -f ../minio ]; then
   911                echo "minio binary not found!, so compiling..."
   912                make docker VERSION=$VERSION;
   913            else
   914                echo "Using binary from cache"
   915                cp ../minio .
   916            fi
   917            docker build -q --no-cache -t minio/minio:$VERSION . -f Dockerfile
   918            echo "Jumping back to console repository to run the integration test"
   919            cd $GITHUB_WORKSPACE;
   920            echo "We are going to use the built image on test-integration";
   921            VERSION="minio/minio:$VERSION";
   922            echo $VERSION;
   923            make test-replication MINIO_VERSION=$VERSION;
   924        - uses: actions/cache@v3
   925          id: coverage-cache-replication
   926          name: Coverage Cache Replication
   927          with:
   928            path: |
   929              ./replication/coverage/
   930            key: ${{ runner.os }}-replication-coverage-2-${{ github.run_id }}
   931  
   932        # To save our replication.out file into an artifact.
   933        # By default, GitHub stores build logs and artifacts for 90 days.
   934        - uses: actions/upload-artifact@v3
   935          with:
   936            name: replication-artifact
   937            path: ./replication/coverage/replication.out
   938            if-no-files-found: error
   939    sso-integration:
   940      name: SSO Integration Test
   941      needs:
   942        - lint-job
   943        - ui-assets
   944        - reuse-golang-dependencies
   945        - semgrep-static-code-analysis
   946        - latest-minio
   947      runs-on: ubuntu-latest
   948  
   949      strategy:
   950        matrix:
   951          go-version: [ 1.21.x ]
   952  
   953      steps:
   954        - name: Check out code
   955          uses: actions/checkout@v3
   956  
   957        - name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
   958          uses: actions/setup-go@v3
   959          with:
   960            go-version: ${{ matrix.go-version }}
   961            cache: true
   962          id: go
   963  
   964        - name: Clone github.com/minio/minio
   965          uses: actions/checkout@master
   966          with:
   967            repository: minio/minio
   968            path: "minio_repository"
   969        - uses: actions/cache@v3
   970          id: minio-latest-cache
   971          name: MinIO Latest Cache
   972          with:
   973            path: |
   974              ./minio
   975            key: ${{ runner.os }}-minio-latest-${{ hashFiles('./minio_repository/go.sum') }}
   976  
   977        - name: Build on ${{ matrix.os }}
   978          run: |
   979            echo "The idea is to build minio image from downloaded repository";
   980            cd $GITHUB_WORKSPACE/minio_repository;
   981            echo "replace github.com/minio/console => ../" >> go.mod
   982  
   983            echo "updates to go.mod needed; to update it: go mod tidy"
   984            go mod tidy -compat=1.19
   985  
   986            echo "Get git version to build MinIO Image";
   987            VERSION=`git rev-parse HEAD`;
   988            echo $VERSION;
   989            echo "Create MinIO image";
   990            if [ ! -f ../minio ]; then
   991                echo "minio binary not found!, so compiling..."
   992                make docker VERSION=$VERSION;
   993            else
   994                echo "Using binary from cache"
   995                cp ../minio .
   996            fi
   997            docker build -q --no-cache -t minio/minio:$VERSION . -f Dockerfile
   998            echo "Jumping back to console repository to run the integration test"
   999            cd $GITHUB_WORKSPACE;
  1000            echo "We are going to use the built image on test-integration";
  1001            VERSION="minio/minio:$VERSION";
  1002            echo $VERSION;
  1003            make test-sso-integration MINIO_VERSION=$VERSION;
  1004        - uses: actions/cache@v3
  1005          id: coverage-cache-sso
  1006          name: Coverage Cache SSO
  1007          with:
  1008            path: |
  1009              ./sso-integration/coverage/
  1010            key: ${{ runner.os }}-sso-coverage-2-${{ github.run_id }}
  1011    coverage:
  1012      name: "Coverage Limit Check"
  1013      needs:
  1014        - b-integration-tests
  1015        - test-api-on-go
  1016        - test-pkg-on-go
  1017        - sso-integration
  1018        - replication
  1019      runs-on: ${{ matrix.os }}
  1020      strategy:
  1021        matrix:
  1022          go-version: [ 1.21.x ]
  1023          os: [ ubuntu-latest ]
  1024      steps:
  1025        - name: Check out code
  1026          uses: actions/checkout@v3
  1027        - name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
  1028          uses: actions/setup-go@v3
  1029          with:
  1030            go-version: ${{ matrix.go-version }}
  1031            cache: true
  1032          id: go
  1033        - name: Check out gocovmerge as a nested repository
  1034          uses: actions/checkout@v3
  1035          with:
  1036            repository: wadey/gocovmerge
  1037            path: gocovmerge
  1038  
  1039        - uses: actions/cache@v3
  1040          id: coverage-cache
  1041          name: Coverage Cache
  1042          with:
  1043            path: |
  1044              ./integration/coverage/
  1045            key: ${{ runner.os }}-coverage-2-${{ github.run_id }}
  1046  
  1047        - uses: actions/cache@v3
  1048          id: coverage-cache-sso
  1049          name: Coverage Cache SSO
  1050          with:
  1051            path: |
  1052              ./sso-integration/coverage/
  1053            key: ${{ runner.os }}-sso-coverage-2-${{ github.run_id }}
  1054  
  1055        - uses: actions/cache@v3
  1056          id: coverage-cache-replication
  1057          name: Coverage Cache Replication
  1058          with:
  1059            path: |
  1060              ./replication/coverage/
  1061            key: ${{ runner.os }}-replication-coverage-2-${{ github.run_id }}
  1062  
  1063        - uses: actions/cache@v3
  1064          id: coverage-cache-api
  1065          name: Coverage Cache API
  1066          with:
  1067            path: |
  1068              ./api/coverage/
  1069            key: ${{ runner.os }}-coverage-api-2-${{ github.run_id }}
  1070  
  1071        - uses: actions/cache@v3
  1072          id: coverage-cache-pkg
  1073          name: Coverage Cache Pkg
  1074          with:
  1075            path: |
  1076              ./pkg/coverage/
  1077            key: ${{ runner.os }}-coverage-pkg-2-${{ github.run_id }}
  1078  
  1079        # Get the replication.out file from the artifact since this is working for self host runner.
  1080        - uses: actions/download-artifact@v3
  1081          with:
  1082            name: replication-artifact
  1083            path: replication/coverage
  1084  
  1085        - name: Get coverage
  1086          run: |
  1087            echo "change directory to gocovmerge"
  1088            cd gocovmerge
  1089            echo "download golang x tools"
  1090            go mod download golang.org/x/tools
  1091            echo "go mod tidy compat mode"
  1092            go mod tidy -compat=1.19
  1093            echo "go build gocoverage.go"
  1094            go build gocovmerge.go
  1095            echo "put together the outs for final coverage resolution"
  1096            ./gocovmerge ../integration/coverage/system.out ../replication/coverage/replication.out ../sso-integration/coverage/sso-system.out ../api/coverage/coverage.out ../pkg/coverage/coverage-pkg.out > all.out
  1097            echo "Download mc for Ubuntu"
  1098            wget -q https://dl.min.io/client/mc/release/linux-amd64/mc
  1099            echo "Change the permissions to execute mc command"
  1100            chmod +x mc
  1101            echo "Only run our test if play is up and running since we require it for replication tests here."
  1102            PLAY_IS_ON=`wget --spider --server-response https://play.min.io:9443/login 2>&1 | grep '200\ OK' | wc -l`
  1103            if [ $PLAY_IS_ON == 1 ]
  1104            then
  1105              echo "Play is up and running, we will proceed with the play part for coverage"
  1106              echo "Create the folder to put the all.out file"
  1107              ./mc mb --ignore-existing play/builds/
  1108              echo "Copy the all.out file to play bucket"
  1109              echo ${{ github.repository }}
  1110              echo ${{ github.event.number }}
  1111              echo ${{ github.run_id }}
  1112              # mc cp can fail due to lack of space: mc: <ERROR> Failed to copy `all.out`.
  1113              # Storage backend has reached its minimum free disk threshold. Please delete a few objects to proceed.
  1114              ./mc cp all.out play/builds/${{ github.repository }}/${{ github.event.number }}/${{ github.run_id }}/ || true
  1115              ./mc cp all.out play/builds/${{ github.repository }}/${{ github.event.number }}/latest/ || true
  1116              go tool cover -html=all.out -o coverage.html
  1117              ./mc cp coverage.html play/builds/${{ github.repository }}/${{ github.event.number }}/${{ github.run_id }}/ || true
  1118              ./mc cp coverage.html play/builds/${{ github.repository }}/${{ github.event.number }}/latest/ || true
  1119              # save all other coverage
  1120              go tool cover -html=../integration/coverage/system.out -o system.html
  1121              ./mc cp system.html play/builds/${{ github.repository }}/${{ github.event.number }}/${{ github.run_id }}/ || true
  1122              ./mc cp system.html play/builds/${{ github.repository }}/${{ github.event.number }}/latest/ || true
  1123              ./mc cp ../integration/coverage/system.out play/builds/${{ github.repository }}/${{ github.event.number }}/${{ github.run_id }}/ || true
  1124              ./mc cp ../integration/coverage/system.out play/builds/${{ github.repository }}/${{ github.event.number }}/latest/ || true
  1125              go tool cover -html=../replication/coverage/replication.out -o replication.html
  1126              ./mc cp replication.html play/builds/${{ github.repository }}/${{ github.event.number }}/${{ github.run_id }}/ || true
  1127              ./mc cp replication.html play/builds/${{ github.repository }}/${{ github.event.number }}/latest/ || true
  1128              ./mc cp ../replication/coverage/replication.out play/builds/${{ github.repository }}/${{ github.event.number }}/${{ github.run_id }}/ || true
  1129              ./mc cp ../replication/coverage/replication.out play/builds/${{ github.repository }}/${{ github.event.number }}/latest/ || true
  1130              go tool cover -html=../sso-integration/coverage/sso-system.out -o sso-system.html
  1131              ./mc cp sso-system.html play/builds/${{ github.repository }}/${{ github.event.number }}/${{ github.run_id }}/ || true
  1132              ./mc cp sso-system.html play/builds/${{ github.repository }}/${{ github.event.number }}/latest/ || true
  1133              ./mc cp ../sso-integration/coverage/sso-system.out play/builds/${{ github.repository }}/${{ github.event.number }}/${{ github.run_id }}/ || true
  1134              ./mc cp ../sso-integration/coverage/sso-system.out play/builds/${{ github.repository }}/${{ github.event.number }}/latest/ || true
  1135              go tool cover -html=../api/coverage/coverage.out -o coverage.html
  1136              ./mc cp coverage.html play/builds/${{ github.repository }}/${{ github.event.number }}/${{ github.run_id }}/ || true
  1137              ./mc cp coverage.html play/builds/${{ github.repository }}/${{ github.event.number }}/latest/ || true
  1138              ./mc cp ../api/coverage/coverage.out play/builds/${{ github.repository }}/${{ github.event.number }}/${{ github.run_id }}/ || true
  1139              ./mc cp ../api/coverage/coverage.out play/builds/${{ github.repository }}/${{ github.event.number }}/latest/ || true
  1140              go tool cover -html=../pkg/coverage/coverage-pkg.out -o coverage-pkg.html
  1141              ./mc cp coverage-pkg.html play/builds/${{ github.repository }}/${{ github.event.number }}/${{ github.run_id }}/ || true
  1142              ./mc cp coverage-pkg.html play/builds/${{ github.repository }}/${{ github.event.number }}/latest/ || true
  1143              ./mc cp ../pkg/coverage/coverage-pkg.out play/builds/${{ github.repository }}/${{ github.event.number }}/${{ github.run_id }}/ || true
  1144              ./mc cp ../pkg/coverage/coverage-pkg.out play/builds/${{ github.repository }}/${{ github.event.number }}/latest/ || true
  1145              ./mc anonymous set public play/builds
  1146            else
  1147              echo "Play is down, please report it on hack channel, no coverage is going to be uploaded!!!"
  1148            fi
  1149            echo "grep to obtain the result"
  1150            go tool cover -func=all.out | grep total > tmp2
  1151            result=`cat tmp2 | awk 'END {print $3}'`
  1152            result=${result%\%}
  1153            threshold=65.0
  1154            echo "Result:"
  1155            echo "$result%"
  1156            if (( $(echo "$result >= $threshold" |bc -l) )); then
  1157              echo "It is equal or greater than threshold ($threshold%), passed!"
  1158            else
  1159              echo "It is smaller than threshold ($threshold%) value, failed!"
  1160              exit 1
  1161            fi
  1162  
  1163    ui-assets-istanbul-coverage:
  1164      name: "Assets with Istanbul Plugin for coverage"
  1165      runs-on: ubuntu-latest
  1166      strategy:
  1167        matrix:
  1168          go-version: [ 1.21.x ]
  1169          os: [ ubuntu-latest ]
  1170      steps:
  1171        - name: Check out code
  1172          uses: actions/checkout@v3
  1173        - name: Read .nvmrc
  1174          id: node_version
  1175          run: echo "$(cat .nvmrc)" && echo "NVMRC=$(cat .nvmrc)" >> $GITHUB_ENV
  1176        - uses: actions/setup-node@v3
  1177          with:
  1178            node-version: ${{ env.NVMRC }}
  1179            cache: "yarn"
  1180            cache-dependency-path: web-app/yarn.lock
  1181        - uses: actions/cache@v3
  1182          id: assets-cache-istanbul-coverage
  1183          name: Assets Cache Istanbul Coverage
  1184          with:
  1185            path: |
  1186              ./web-app/build/
  1187            key: ${{ runner.os }}-assets-istanbul-coverage-${{ github.run_id }}
  1188        - name: Install Dependencies
  1189          working-directory: ./web-app
  1190          continue-on-error: false
  1191          run: |
  1192            yarn install --frozen-lockfile --immutable
  1193        - name: Check for Warnings in build output
  1194          working-directory: ./web-app
  1195          continue-on-error: false
  1196          run: |
  1197            ./check-warnings-istanbul-coverage.sh
  1198  
  1199    compile-binary-istanbul-coverage:
  1200      name: "Compile Console Binary with Istanbul Plugin for Coverage"
  1201      needs:
  1202        - lint-job
  1203        - ui-assets-istanbul-coverage
  1204        - reuse-golang-dependencies
  1205        - semgrep-static-code-analysis
  1206      runs-on: ${{ matrix.os }}
  1207      strategy:
  1208        matrix:
  1209          go-version: [ 1.21.x ]
  1210          os: [ ubuntu-latest ]
  1211      steps:
  1212        - name: Check out code
  1213          uses: actions/checkout@v3
  1214  
  1215        - name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
  1216          uses: actions/setup-go@v3
  1217          with:
  1218            go-version: ${{ matrix.go-version }}
  1219            cache: true
  1220          id: go
  1221        - uses: actions/cache@v3
  1222          name: Console Binary Cache Istanbul Coverage
  1223          with:
  1224            path: |
  1225              ./console
  1226            key: ${{ runner.os }}-binary-istanbul-coverage-${{ github.run_id }}
  1227        - uses: actions/cache@v3
  1228          id: assets-cache-istanbul-coverage
  1229          name: Assets Cache Istanbul Coverage
  1230          with:
  1231            path: |
  1232              ./web-app/build/
  1233            key: ${{ runner.os }}-assets-istanbul-coverage-${{ github.run_id }}
  1234        - name: Build on ${{ matrix.os }}
  1235          env:
  1236            GO111MODULE: on
  1237            GOOS: linux
  1238          run: |
  1239            make console
  1240  
  1241    playwright:
  1242      needs:
  1243        - compile-binary-istanbul-coverage
  1244      timeout-minutes: 60
  1245      runs-on: ubuntu-latest
  1246      steps:
  1247        - uses: actions/checkout@v3
  1248        - uses: actions/setup-node@v3
  1249          with:
  1250            node-version: 18
  1251  
  1252        - name: Install dependencies
  1253          run: |
  1254            echo "Install dependencies"
  1255            cd $GITHUB_WORKSPACE/web-app
  1256            yarn add -D playwright
  1257            yarn add -D babel-plugin-istanbul
  1258            yarn add -D nyc
  1259            yarn add -D react-app-rewired
  1260            yarn add -D create-react-app
  1261            yarn add -D @playwright/test
  1262            yarn init -y
  1263            echo "yarn install"
  1264            yarn install
  1265  
  1266        - name: Install Playwright Browsers
  1267          run: npx playwright install --with-deps
  1268  
  1269        - uses: actions/cache@v3
  1270          name: Console Binary Cache Istanbul Coverage
  1271          with:
  1272            path: |
  1273              ./console
  1274            key: ${{ runner.os }}-binary-istanbul-coverage-${{ github.run_id }}
  1275  
  1276        - name: Start Console, front-end app and initialize users/policies
  1277          run: |
  1278            (./console server) & (make initialize-permissions)
  1279  
  1280        - name: Run Playwright tests
  1281          run: |
  1282            echo "Run tests under playwright folder only"
  1283            cd $GITHUB_WORKSPACE/web-app
  1284            yarn remove playwright
  1285            yarn add --dev @playwright/test
  1286            echo "npx playwright test"
  1287            npx playwright test # To run the tests
  1288            echo "npx nyc report"
  1289            npx nyc report # To see report printed in logs as text
  1290            echo "npx nyc report --reporter=html"
  1291            npx nyc report --reporter=html # to see report in ./coverage/index.html
  1292        - uses: actions/upload-artifact@v3
  1293          if: always()
  1294          with:
  1295            name: playwright-report
  1296            path: playwright-report/
  1297            retention-days: 30
  1298        - uses: actions/upload-artifact@v3
  1299          if: always()
  1300          with:
  1301            name: coverage
  1302            path: coverage/
  1303            retention-days: 30