From 706ddb9a30b0476c8f19aebaa79a4579f59ea4a9 Mon Sep 17 00:00:00 2001 From: Erik Jaegervall Date: Thu, 21 Mar 2024 14:09:47 +0100 Subject: [PATCH] Fix workflows Previously no docker containers were published --- .github/actions/copy-from-oci/action.yml | 60 ------------------- .../post-container-location/action.yml | 24 -------- .../workflows/kuksa_databroker-cli_build.yml | 9 ++- .github/workflows/kuksa_databroker_build.yml | 28 +++------ .github/workflows/pre-commit.yml | 8 ++- .pre-commit-config.yaml | 13 ++++ 6 files changed, 31 insertions(+), 111 deletions(-) delete mode 100644 .github/actions/copy-from-oci/action.yml delete mode 100644 .github/actions/post-container-location/action.yml create mode 100644 .pre-commit-config.yaml diff --git a/.github/actions/copy-from-oci/action.yml b/.github/actions/copy-from-oci/action.yml deleted file mode 100644 index a82957b1..00000000 --- a/.github/actions/copy-from-oci/action.yml +++ /dev/null @@ -1,60 +0,0 @@ - -name: Extract from OCI image -description: Can copy files out of an OCI image - -inputs: - platform: - required: true - type: choice - description: Choose platform, e.g. linux/arm64 - options: - - linux/arm64 - - linux/amd64 - - linux/riscv64 - image: - required: true - type: string - description: The OCI image - src: - required: true - type: string - description: Path inside container - id: - required: true - type: string - description: | - This will be the name of the temporary container, making sure we do not leave any stale containers around - (we try deleting and before and after running this, so we can recover should a workflow for a given id fail before cleaning up) - Will be used for artifact name (if export=true) and to identify - This will also be created as directory in cwd. - !No special characters allowed "/" ! - export: - required: false - default: false - description: Archive dest and export as Action artifact - transform: - required: false - description: Optionally applying chosen --transform to tar when export is set to true - - -runs: - using: "composite" - steps: - - shell: bash - run: | - mkdir -p ${{ inputs.id }} - docker rm ${{ inputs.id }} || true - docker create --name ${{ inputs.id }} --platform ${{ inputs.platform }} ${{ inputs.image }} - docker cp ${{ inputs.id }}:${{ inputs.src }} ${{ inputs.id }} - docker rm ${{ inputs.id }} - - - - if: inputs.export == 'true' - shell: bash - run: tar -czf ${{ inputs.id }}.tar.gz -C ${{ inputs.id }} --transform "${{ inputs.transform }}" . - - - if: inputs.export == 'true' - uses: actions/upload-artifact@v4 - with: - name: ${{ inputs.id }} - path: ${{ inputs.id }}.tar.gz diff --git a/.github/actions/post-container-location/action.yml b/.github/actions/post-container-location/action.yml deleted file mode 100644 index 757b7c2b..00000000 --- a/.github/actions/post-container-location/action.yml +++ /dev/null @@ -1,24 +0,0 @@ - -name: Post container location -description: Post snippet to pull and run test container - - - - -inputs: - image: - required: true - type: string - description: The OCI image - -runs: - using: "composite" - steps: - - shell: bash - run: | - echo "## :hatching_chick: Moin!" >> $GITHUB_STEP_SUMMARY - echo "Something new is in the world" >> $GITHUB_STEP_SUMMARY - echo -e "\nImages for testing temporarily available at \`${{ inputs.image }}\`" >> $GITHUB_STEP_SUMMARY - echo -e "\n\`\`\`\ndocker pull ${{ inputs.image }}\n\`\`\`" >> $GITHUB_STEP_SUMMARY - echo -e "\n\`\`\`\ndocker run --rm -it --net=host ${{ inputs.image }}\n\`\`\`" >> $GITHUB_STEP_SUMMARY - diff --git a/.github/workflows/kuksa_databroker-cli_build.yml b/.github/workflows/kuksa_databroker-cli_build.yml index 268dcf49..8c4618d7 100644 --- a/.github/workflows/kuksa_databroker-cli_build.yml +++ b/.github/workflows/kuksa_databroker-cli_build.yml @@ -15,7 +15,7 @@ name: Build kuksa-databroker-cli on: push: - branches: [ master ] + branches: [ main ] pull_request: paths: - ".github/workflows/kuksa_databroker-cli_build.yml" @@ -30,6 +30,10 @@ concurrency: group: ${{ github.ref }}-${{ github.workflow }} cancel-in-progress: true +# Needed as default_workflow_permissions is "read" +permissions: + packages: write + jobs: lint: name: Lint @@ -152,9 +156,8 @@ jobs: # Same problem as described in https://github.com/orgs/community/discussions/45969 provenance: false - - name: Posting message - uses: ./.github/actions/post-container-location + uses: eclipse-kuksa/kuksa-actions/post-container-location@2 with: image: ttl.sh/eclipse-kuksa/kuksa-databroker-cli-${{github.sha}} diff --git a/.github/workflows/kuksa_databroker_build.yml b/.github/workflows/kuksa_databroker_build.yml index ffae59c3..6eeb0b1e 100644 --- a/.github/workflows/kuksa_databroker_build.yml +++ b/.github/workflows/kuksa_databroker_build.yml @@ -15,7 +15,7 @@ name: Build kuksa-databroker on: push: - branches: [ master ] + branches: [ main] pull_request: workflow_call: workflow_dispatch: @@ -24,6 +24,10 @@ concurrency: group: ${{ github.ref }}-${{ github.workflow }} cancel-in-progress: true +# Needed as default_workflow_permissions is "read" +permissions: + packages: write + jobs: lint: name: Lint @@ -77,6 +81,7 @@ jobs: - name: Generate code coverage run: cargo llvm-cov --all-features --workspace --lcov --output-path lcov.info - name: Upload coverage to Codecov + # To use v4 a token must be specifed by "token: ${{ secrets.CODECOV_TOKEN }}"" uses: codecov/codecov-action@v3 with: files: lcov.info @@ -230,29 +235,10 @@ jobs: provenance: false - name: Posting message - uses: ./.github/actions/post-container-location + uses: eclipse-kuksa/kuksa-actions/post-container-location@2 with: image: ttl.sh/eclipse-kuksa/kuksa-databroker-${{github.sha}} - # - name: "Archiving AMD64 artifacts" - # uses: actions/upload-artifact@v4 - # with: - # name: databroker-amd64 - # path: ${{github.workspace}}/dist/amd64 - - # - name: "Archiving ARM64 artifacts" - # uses: actions/upload-artifact@v4 - # with: - # name: databroker-arm64 - # path: ${{github.workspace}}/dist/arm64 - - # - name: "Archiving RISCV64 artifacts" - # uses: actions/upload-artifact@v4 - # with: - # name: databroker-riscv64 - # path: ${{github.workspace}}/dist/riscv64 - - integration-test: name: Run integration test runs-on: ubuntu-latest diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index ec0a66f1..09b5322a 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -15,8 +15,10 @@ jobs: - uses: actions/checkout@v4 with: # required to grab the history of the PR - fetch-depth: 0 - - uses: actions/setup-python@v3 - - uses: pre-commit/action@v3.0.0 + fetch-depth: 0 + - uses: actions/setup-python@v5 + with: + python-version: '3.10' + - uses: pre-commit/action@v3.0.1 with: extra_args: --color=always --from-ref ${{ github.event.pull_request.base.sha }} --to-ref ${{ github.event.pull_request.head.sha }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..3f9f18d7 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,13 @@ +# See https://pre-commit.com for more information +# See https://pre-commit.com/hooks.html for more hooks +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v3.2.0 + hooks: + - id: trailing-whitespace + exclude_types: ["dbc"] + - id: end-of-file-fixer + exclude_types: ["dbc", "json"] + exclude: \.token$ + - id: check-yaml + - id: check-added-large-files