Jaykul / RequiredModules

A simpler tool for installing dependencies
MIT License
21 stars 3 forks source link

Help! Can't get `PoshCode/Actions/install-requiredmodules@v1` to work in my publish action #6

Open tig opened 1 year ago

tig commented 1 year ago
# We use `MainLine Development`. See https://gitversion.net/docs/reference/modes/mainline

name: Publish to PowerShell Gallery

on:
  push:
    branches: 
      - main

jobs:
  build:
    runs-on: windows-latest
    steps:
    - name: Checkout
      uses: actions/checkout@v2

    - name: GitVersion
      id: gitversion
      uses: PoshCode/Actions/gitversion@v1

    - name: Install-RequiredModules
      uses: PoshCode/Actions/install-requiredmodules@v1

    - name: Build Module
      id: build
      uses: PoshCode/actions/build-module@v1
      with:
        path: ${{github.workspace}}/Source
        version: ${{ steps.gitversion.outputs.LegacySemVerPadded }}
        destination: ${{github.workspace}}/output

    - name: Upload Build Output
      uses: actions/upload-artifact@v3
      with:
        name: Modules
        path: ${{github.workspace}}/output

    - name: Upload Tests
      uses: actions/upload-artifact@v3
      with:
        name: PesterTests
        path: ${{github.workspace}}/Tests

    - name: Upload RequiredModules.psd1
      uses: actions/upload-artifact@v3
      with:
        name: RequiredModules
        path: ${{github.workspace}}/RequiredModules.psd1

    - name: Upload PSScriptAnalyzerSettings.psd1
      uses: actions/upload-artifact@v3
      with:
        name: ScriptAnalyzer
        path: ${{github.workspace}}/PSScriptAnalyzerSettings.psd1

  lint:
    needs: build
    name: Run PSScriptAnalyzer
    runs-on: ubuntu-latest
    steps:
    - name: Download Build Output
      uses: actions/download-artifact@v3
    - name: Invoke-ScriptAnalyzer
      uses: devblackops/github-action-psscriptanalyzer@master
      with:
        rootPath: Modules/F7History
        repoToken: ${{ secrets.GITHUB_TOKEN }}

  test:
    needs: build
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [windows-latest, ubuntu-latest, macos-latest]
    steps:
    - name: Download Build Output
      uses: actions/download-artifact@v3

    - name: Install Required Modules
      uses: PoshCode/Actions/install-requiredmodules@v1
      with: 
        requiredModules-path: ${{github.workspace}}/RequiredModules/RequiredModules.psd1

    # see https://github.com/Jaykul/RequiredModules/issues/6
    - name: Manually Install Modules F7History is dependent on
      shell: pwsh
      run: |
            Install-Module -Name Microsoft.PowerShell.ConsoleGuiTools -Force -SkipPublisherCheck -Scope CurrentUser
            Install-Module -Name PSReadLine -Force -SkipPublisherCheck -Scope CurrentUser

    - uses: PoshCode/Actions/pester@v1
      with:
        codeCoveragePath: Modules/F7History
        moduleUnderTest: F7History
        additionalModulePaths: ${{github.workspace}}/Modules

    - name: Publish Test Results
      uses: zyborg/dotnet-tests-report@v1
      with:
        test_results_path: results.xml

    - name: Upload Results
      uses: actions/upload-artifact@v3
      with:
        name: Pester Results
        path: ${{github.workspace}}/*.xml

  publish:
    needs: 
      - build
      - test 
    runs-on: ubuntu-latest
    steps:
      - name: Download Build Output
        uses: actions/download-artifact@v3

      - name: Display structure of downloaded files
        run: ls -R

      - name: Install-RequiredModules
        uses: PoshCode/Actions/install-requiredmodules@v1
        with: 
          requiredModules-path: ${{github.workspace}}/RequiredModules/RequiredModules.psd1

      # see https://github.com/Jaykul/RequiredModules/issues/6
      - name: Manually Install Modules F7History is dependent on
        shell: pwsh
        run: |
            Install-Module -Name Microsoft.PowerShell.ConsoleGuiTools -Force -SkipPublisherCheck -Scope CurrentUser
            Install-Module -Name PSReadLine -Force -SkipPublisherCheck -Scope CurrentUser

      - name: Publish Module to PowerShell Gallery
        shell: pwsh
        run: |
              Publish-Module -Path ${{github.workspace}}/Modules/F7History -NuGetApiKey ${{ secrets.F7HISTORY_GALLERY_KEY }}

Note the "Manually Install Modules F7History is dependent on" items. But I'd rather get Install-RequiredModules to do this.

Here's what happens:

image

I had to use run: ls -R to discover that RequiredModules.psd1 is being uploaded to ./RequiredModules and thought that would fix it.

It would help if install-requiredmodules had better logging too.

What am i doing wrong?

Jaykul commented 4 months ago

I honestly can't tell what's happening there, and have obviously slightly abandoned the Github workflow tasks (because I've started using Earthly). My guess is that the way I tried to cache things for you instead of making you call the cache task is broken because of changes to caching. I need to push this issue over to the Actions repo.