diff --git a/.github/workflows/coveralls.yml b/.github/workflows/coveralls.yml index 4501aa7..e103b98 100644 --- a/.github/workflows/coveralls.yml +++ b/.github/workflows/coveralls.yml @@ -8,5 +8,44 @@ jobs: run: runs-on: ubuntu-latest steps: - - name: Coveralls - uses: coverallsapp/github-action@v2 + - name: 'Download artifact' + uses: actions/github-script@v6 + with: + script: | + let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({ + owner: context.repo.owner, + repo: context.repo.repo, + run_id: context.payload.workflow_run.id, + }); + let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => { + return artifact.name == "coverager" + })[0]; + let download = await github.rest.actions.downloadArtifact({ + owner: context.repo.owner, + repo: context.repo.repo, + artifact_id: matchArtifact.id, + archive_format: 'zip', + }); + let fs = require('fs'); + fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/coverager.zip`, Buffer.from(download.data)); + + - name: 'Unzip artifact' + run: unzip coverager.zip + + - name: Coveralls + uses: coverallsapp/github-action@v2 + + - name: 'Comment on PR' + uses: actions/github-script@v6 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + let fs = require('fs'); + let issue_number = Number(fs.readFileSync('./coverage.json')); + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: issue_number, + body: 'Thank you for the PR!' + }); + diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 4a923e5..3f677ac 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -30,3 +30,12 @@ jobs: bundler-cache: true # runs 'bundle install' and caches installed gems automatically - name: Run tests run: bundle exec rake + + - name: Save Coverage report + run: | + mkdir -p ./cc + cp /home/runner/work/space_invaders/space_invaders/coverage/.resultset.json ./cc/coverage.json + - uses: actions/upload-artifact@v4 + with: + name: coverager + path: cc/ diff --git a/.github/workflows/use_data.yml b/.github/workflows/use_data.yml index 1507b12..65732c5 100644 --- a/.github/workflows/use_data.yml +++ b/.github/workflows/use_data.yml @@ -45,5 +45,5 @@ jobs: owner: context.repo.owner, repo: context.repo.repo, issue_number: issue_number, - body: 'Thank you for the PR!' + body: `Thank you for the PR! ${issue_number}` }); \ No newline at end of file diff --git a/app/invaders/invader.rb b/app/invaders/invader.rb index 2c33b5d..23963fc 100644 --- a/app/invaders/invader.rb +++ b/app/invaders/invader.rb @@ -1,6 +1,7 @@ class Invader private + # a comment attr_reader :face attr_reader :radar_signal