Github actions Pylint 步骤无法创建带有测试作业的目录

Github actions Pylint step unable to create directory with test job

实际上,我正在尝试使用 CI/CD 和 Heroku 部署完成我的第一个 GitHub 操作,但我收到此错误。

错误图片:

这是我的 public 存储库。
https://github.com/jovicon/the_empire_strikes_back_challenge
“开发”分支中的所有内容都已更新

这是我的测试作业: (full file)
注意:当我评论 Pylint step 时一切正常。

test:
    name: Test Docker Image
    runs-on: ubuntu-latest
    needs: build
    steps:
      - name: Checkout master
        uses: actions/checkout@v1
      - name: Log in to GitHub Packages
        run: echo ${GITHUB_TOKEN} | docker login -u ${GITHUB_ACTOR} --password-stdin docker.pkg.github.com
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      - name: Pull image
        run: |
          docker pull ${{ env.IMAGE }}:latest || true
      - name: Build image
        run: |
          docker build \
            --cache-from ${{ env.IMAGE }}:latest \
            --tag ${{ env.IMAGE }}:latest \
            --file ./backend/Dockerfile.prod \
            "./backend"
      - name: Run container
        run: |
          docker run \
            -d \
            --name fastapi-tdd \
            -e PORT=8765 \
            -e ENVIRONMENT=dev \
            -e DATABASE_TEST_URL=sqlite://sqlite.db \
            -p 5003:8765 \
            ${{ env.IMAGE }}:latest
      - name: Pytest
        run: docker exec fastapi-tdd python -m pytest .
      - name: Pylint
        run: docker exec fastapi-tdd python -m pylint app/
      - name: Black
        run: docker exec fastapi-tdd python -m black . --check
      - name: isort
        run: docker exec fastapi-tdd /bin/sh -c "python -m isort ./*/*.py --check-only"

我也把我的Dockerfile.prod放在这里:

# pull official base image
FROM python:3.8.3-slim-buster

# create directory for the app user
RUN mkdir -p /home/app

# create the app user
RUN addgroup --system app && adduser --system --group app

# create the appropriate directories
ENV HOME=/home/app
ENV APP_HOME=/home/app/web
RUN mkdir $APP_HOME
WORKDIR $APP_HOME

# set environment varibles
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
ENV ENVIRONMENT prod
ENV TESTING 0

# install system dependencies
RUN apt-get update \
    && apt-get -y install netcat gcc postgresql \
    && apt-get clean

# install python dependencies
RUN pip install --upgrade pip
COPY ./requirements.txt .
COPY ./dev-requirements.txt .
RUN pip install -r requirements.txt
RUN pip install -r dev-requirements.txt

# add app
COPY . .

RUN chmod 755 $HOME

# chown all the files to the app user
RUN chown -R app:app $APP_HOME

# change to the app user
USER app

# run gunicorn
CMD gunicorn --bind 0.0.0.0:$PORT app.main:app -k uvicorn.workers.UvicornWorker

您正在将默认用户的 $HOME 目录权限设置为 755。 chown -R app:app $APP_HOME 仅针对 $APP_HOME,它只是 $HOME.

的子目录

因此,用户 app 没有对 $HOME 的写入权限,并且 pylint 无法创建目录 /home/app/.pylint.d.